Package net.sf.saxon.om
Class GenericTreeInfo
- java.lang.Object
-
- net.sf.saxon.om.GenericTreeInfo
-
- All Implemented Interfaces:
javax.xml.transform.Source
,TreeInfo
- Direct Known Subclasses:
AxiomDocument
,DocumentWrapper
,DOM4JDocumentWrapper
,DominoTree
,JDOM2DocumentWrapper
,RebasedDocument
,SpaceStrippedDocument
,TinyTree
,TypeStrippedDocument
,VirtualTreeInfo
public class GenericTreeInfo extends java.lang.Object implements TreeInfo, javax.xml.transform.Source
A generic (model-independent) implementation of the TreeInfo interface, suitable for use with all tree models where the object representing the document node does not itself act as the TreeInfo implementation
-
-
Constructor Summary
Constructors Constructor Description GenericTreeInfo(Configuration config)
Create the TreeInfoGenericTreeInfo(Configuration config, NodeInfo root)
Create the TreeInfo
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Configuration
getConfiguration()
Get the Configuration to which this tree belongslong
getDocumentNumber()
Get the document number, which identifies this tree uniquely within a Configurationjava.lang.String
getPublicId()
Get the Public ID of the entity containing the node.NodeInfo
getRootNode()
Get the NodeInfo object representing the root of the tree (not necessarily a document node)SpaceStrippingRule
getSpaceStrippingRule()
Get details of space stripping action that was applied to this document during construction.java.lang.String
getSystemId()
Get the systemId of the document nodejava.lang.String[]
getUnparsedEntity(java.lang.String name)
Get the unparsed entity with a given namejava.util.Iterator<java.lang.String>
getUnparsedEntityNames()
Get the list of unparsed entities defined in this documentjava.lang.Object
getUserData(java.lang.String key)
Get user data held in the tree.boolean
isStreamed()
NodeInfo
selectID(java.lang.String id, boolean getParent)
Get the element with a given ID, if anyvoid
setConfiguration(Configuration config)
Set the configuration (containing the name pool used for all names in this tree)void
setDocumentNumber(long documentNumber)
Set the document number, which identifies this tree uniquely within a Configurationvoid
setRootNode(NodeInfo root)
Set the root node of the treevoid
setSpaceStrippingRule(SpaceStrippingRule rule)
Set details of space stripping action that was applied to this document during construction.void
setSystemId(java.lang.String systemId)
Set the systemId of the document node (for most implementations, this is likely to be the systemId of the entire tree)void
setUserData(java.lang.String key, java.lang.Object value)
Set user data on the tree.
-
-
-
Field Detail
-
root
protected NodeInfo root
-
-
Constructor Detail
-
GenericTreeInfo
public GenericTreeInfo(Configuration config)
Create the TreeInfo- Parameters:
config
- the Saxon Configuration
-
GenericTreeInfo
public GenericTreeInfo(Configuration config, NodeInfo root)
Create the TreeInfo- Parameters:
config
- the Saxon Configurationroot
- the root node- Throws:
java.lang.IllegalArgumentException
- if the supplied node is not parentless
-
-
Method Detail
-
setConfiguration
public void setConfiguration(Configuration config)
Set the configuration (containing the name pool used for all names in this tree)- Parameters:
config
- the configuration
-
getConfiguration
public Configuration getConfiguration()
Get the Configuration to which this tree belongs- Specified by:
getConfiguration
in interfaceTreeInfo
- Returns:
- the configuration
-
setRootNode
public void setRootNode(NodeInfo root)
Set the root node of the tree- Parameters:
root
- the root node (not necessarily a document node)- Throws:
java.lang.IllegalArgumentException
- if the supplied node is not parentless
-
getRootNode
public NodeInfo getRootNode()
Get the NodeInfo object representing the root of the tree (not necessarily a document node)- Specified by:
getRootNode
in interfaceTreeInfo
- Returns:
- the root node
-
setSystemId
public void setSystemId(java.lang.String systemId)
Set the systemId of the document node (for most implementations, this is likely to be the systemId of the entire tree)- Specified by:
setSystemId
in interfacejavax.xml.transform.Source
- Parameters:
systemId
- the system ID
-
getSystemId
public java.lang.String getSystemId()
Get the systemId of the document node- Specified by:
getSystemId
in interfacejavax.xml.transform.Source
- Returns:
- the system ID
-
getPublicId
public java.lang.String getPublicId()
Get the Public ID of the entity containing the node.- Returns:
- null (always)
- Since:
- 9.7
-
getDocumentNumber
public long getDocumentNumber()
Get the document number, which identifies this tree uniquely within a Configuration- Specified by:
getDocumentNumber
in interfaceTreeInfo
- Returns:
- the document number
-
setDocumentNumber
public void setDocumentNumber(long documentNumber)
Set the document number, which identifies this tree uniquely within a Configuration- Parameters:
documentNumber
- the document number allocated to this tree
-
selectID
public NodeInfo selectID(java.lang.String id, boolean getParent)
Get the element with a given ID, if any- Specified by:
selectID
in interfaceTreeInfo
- Parameters:
id
- the required ID valuegetParent
- true if running the element-with-id() function rather than the id() function; the difference is that in the case of an element of type xs:ID, the parent of the element should be returned, not the element itself.- Returns:
- the element with the given ID, or null if there is no such ID present (or if the parser has not notified attributes as being of type ID)
- Since:
- 8.4. Second argument added in 9.2.
-
getUnparsedEntityNames
public java.util.Iterator<java.lang.String> getUnparsedEntityNames()
Get the list of unparsed entities defined in this document- Specified by:
getUnparsedEntityNames
in interfaceTreeInfo
- Returns:
- an Iterator, whose items are of type String, containing the names of all unparsed entities defined in this document. If there are no unparsed entities or if the information is not available then an empty iterator is returned
- Since:
- 9.1
-
getUnparsedEntity
public java.lang.String[] getUnparsedEntity(java.lang.String name)
Get the unparsed entity with a given name- Specified by:
getUnparsedEntity
in interfaceTreeInfo
- Parameters:
name
- the name of the entity- Returns:
- if the entity exists, return an array of two Strings, the first holding the system ID of the entity (as an absolute URI if possible), the second holding the public ID if there is one, or null if not. If the entity does not exist, the method returns null. Applications should be written on the assumption that this array may be extended in the future to provide additional information.
- Since:
- 8.4
-
setSpaceStrippingRule
public void setSpaceStrippingRule(SpaceStrippingRule rule)
Set details of space stripping action that was applied to this document during construction. This ensures that space stripping is not applied twice to the same document.- Specified by:
setSpaceStrippingRule
in interfaceTreeInfo
- Parameters:
rule
- details of the space stripping rules that have been applied to this document during its construction.- Since:
- 9.9
-
getSpaceStrippingRule
public SpaceStrippingRule getSpaceStrippingRule()
Get details of space stripping action that was applied to this document during construction. This ensures that space stripping is not applied twice to the same document.- Specified by:
getSpaceStrippingRule
in interfaceTreeInfo
- Returns:
- details of the space stripping rules that have been applied to this
document during its construction. By default, returns
NoElementsSpaceStrippingRule
, indicating that no space stripping has been applied - Since:
- 9.9
-
setUserData
public void setUserData(java.lang.String key, java.lang.Object value)
Set user data on the tree. The user data can be retrieved subsequently usinggetUserData(java.lang.String)
- Specified by:
setUserData
in interfaceTreeInfo
- Parameters:
key
- A string giving the name of the property to be set. Clients are responsible for choosing a key that is likely to be unique. Must not be null. Keys used internally by Saxon are prefixed "saxon:".value
- The value to be set for the property. May be null, which effectively
-
getUserData
public java.lang.Object getUserData(java.lang.String key)
Get user data held in the tree. This retrieves properties previously set usingsetUserData(java.lang.String, java.lang.Object)
- Specified by:
getUserData
in interfaceTreeInfo
- Parameters:
key
- A string giving the name of the property to be retrieved.- Returns:
- the value of the property, or null if the property has not been defined.
-
isStreamed
public boolean isStreamed()
-
-