Class GenericTreeInfo

java.lang.Object
net.sf.saxon.om.GenericTreeInfo
All Implemented Interfaces:
Source, TreeInfo
Direct Known Subclasses:
AxiomDocument, DocumentWrapper, DOM4JDocumentWrapper, DominoTree, JDOM2DocumentWrapper, RebasedDocument, SpaceStrippedDocument, TinyTree, TypeStrippedDocument, VirtualTreeInfo

public class GenericTreeInfo extends Object implements TreeInfo, 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
  • Field Details

  • Constructor Details

    • 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 Configuration
      root - the root node
      Throws:
      IllegalArgumentException - if the supplied node is not parentless
  • Method Details

    • 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 interface TreeInfo
      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:
      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 interface TreeInfo
      Returns:
      the root node
    • setSystemId

      public void setSystemId(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 interface Source
      Parameters:
      systemId - the system ID
    • getSystemId

      public String getSystemId()
      Get the systemId of the document node
      Specified by:
      getSystemId in interface Source
      Returns:
      the system ID
    • getPublicId

      public 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 interface TreeInfo
      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(String id, boolean getParent)
      Get the element with a given ID, if any
      Specified by:
      selectID in interface TreeInfo
      Parameters:
      id - the required ID value
      getParent - 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.
    • setDurability

      public void setDurability(Durability durability)
      Set the durability property of this node tree
      Parameters:
      durability - the durability. This (a) indicates how long the node is expected to remain in memory, and (b) whether the node is mutable. This information is used when the node appears in the arguments to a memo function.
    • getDurability

      public Durability getDurability()
      Description copied from interface: TreeInfo
      Get the durability of nodes in the tree. This affects how they are handled in a memo function cache, to optimize memory and garbage collection. By default, all nodes are considered durable unless otherwise specified
      Specified by:
      getDurability in interface TreeInfo
      Returns:
      the durability property of this node tree
    • isMutable

      public boolean isMutable()
      Description copied from interface: TreeInfo
      Ask whether the tree is mutable. A mutable tree can be modified (without changes to node identity) using XQuery Update primitives, or equivalents in other languages (such as Saxon XSLT extensions). "Mutable" here means mutable using XSLT/XQuery mechanisms, not using subversive lower-level mechanisms such as external DOM updates. To be mutable, it is necessary that its nodes implement the MutableNodeInfo interface; but this is not sufficient, because some tree implementations that support mutability interfaces may have optimizations for the case of non-mutability.
      Specified by:
      isMutable in interface TreeInfo
      Returns:
      true if the tree is mutable
    • getUnparsedEntityNames

      public Iterator<String> getUnparsedEntityNames()
      Get the list of unparsed entities defined in this document
      Specified by:
      getUnparsedEntityNames in interface TreeInfo
      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 String[] getUnparsedEntity(String name)
      Get the unparsed entity with a given name
      Specified by:
      getUnparsedEntity in interface TreeInfo
      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 interface TreeInfo
      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 interface TreeInfo
      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(String key, Object value)
      Set user data on the tree. The user data can be retrieved subsequently using getUserData(java.lang.String)
      Specified by:
      setUserData in interface TreeInfo
      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 Object getUserData(String key)
      Get user data held in the tree. This retrieves properties previously set using setUserData(java.lang.String, java.lang.Object)
      Specified by:
      getUserData in interface TreeInfo
      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()