Class DTMDefaultBase

java.lang.Object
org.loboevolution.apache.xml.dtm.ref.DTMDefaultBase
All Implemented Interfaces:
DTM
Direct Known Subclasses:
DTMDefaultBaseTraversers

public abstract class DTMDefaultBase extends Object implements DTM
The DTMDefaultBase class serves as a helper base for DTMs. It sets up structures for navigation and type, while leaving data management and construction to the derived classes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default block size of the node arrays
    static final int
    The number of blocks for the node arrays
    static final int
    The number of blocks used for small documents & RTFs
    protected final String
    The base URI for this document.
    protected final SuballocatedIntVector
    The document identity number(s).
    protected int[][][]
    These hold indexes to elements based on namespace and local name.
    protected final ExpandedNameTable
    The table for exandedNameID lookups.
    protected final SuballocatedIntVector
    The expanded names, one array element for each node.
    protected final SuballocatedIntVector
    First child values, one array element for each node.
    protected final boolean
    true if indexing is turned on.
    The DTM manager who "owns" this DTM.
    m_mgr cast to DTMManagerDefault, or null if it isn't an instance (Efficiency hook)
    SuballocatedIntVector of elements at which corresponding namespaceDeclSets were defined
    Vector of SuballocatedIntVectors of NS decl sets
    protected final SuballocatedIntVector
    Next sibling values, one array element for each node.
    protected final SuballocatedIntVector
    Previous sibling values, one array element for each node.
    Previous sibling values, one array element for each node.
    protected int
    The number of nodes, which is also used to determine the next node index.
    protected DTMAxisTraverser[]
    Stateless axis traversers, lazely built.
    protected static final int
    The value to use when the information has not been built yet.
    static final int
    The identity of the root node.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DTMDefaultBase(DTMManager mgr, Source source, int dtmIdentity, boolean doIndexing)
    Construct a DTMDefaultBase object using the default block size.
    DTMDefaultBase(DTMManager mgr, Source source, int dtmIdentity, boolean doIndexing, int blocksize, boolean usePrevsib)
    Construct a DTMDefaultBase object from a DOM node.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected int
    _exptype(int identity)
    Get the expanded type ID for the given node identity.
    protected int
    _firstch(int identity)
    Get the first child for the given node identity.
    protected int
    _level(int identity)
    Get the level in the tree for the given node identity.
    protected int
    _nextsib(int identity)
    Get the next sibling for the given node identity.
    protected int
    _parent(int identity)
    Get the parent for the given node identity.
    protected int
    _prevsib(int identity)
    Get the previous sibling for the given node identity.
    protected short
    _type(int identity)
    Get the simple type ID for the given node identity.
    protected void
    declareNamespaceInContext(int elementNodeIndex, int namespaceNodeIndex)
    Build table of namespace declaration locations during DTM construction.
    dumpNode(int nodeHandle)
    Diagnostics function to dump a single node.
    protected void
    ensureSizeOfIndex(int namespaceID, int LocalNameID)
    Ensure that the size of the element indexes can hold the information.
    protected void
    Simple error for asserts and the like.
    protected int
    findGTE(int[] list, int start, int len, int value)
    Find the first index that occurs in the list that is greater than or equal to the given value.
    protected int
    Subroutine: Locate the specified node within m_namespaceDeclSetElements, or the last element which preceeds it in document order
    findNamespaceContext(int elementNodeIndex)
    Retrieve list of namespace declaration locations active at this node.
    abstract int
    getAttributeNode(int nodeHandle, String namespaceURI, String name)
    Retrieves an attribute node by local name and namespace URI
    int
    Given a DTM which contains only a single document, find the Node Handle of the Document node.
    int
    getDocumentRoot(int nodeHandle)
    Given a node handle, find the owning document node.
    abstract int
    Returns the Element whose ID is given by elementId.
    int
    getExpandedTypeID(int nodeHandle)
    Given a node handle, return an ID that represents the node's expanded name.
    int
    getExpandedTypeID(String namespace, String localName, int type)
    Given an expanded name, return an ID.
    int
    getFirstAttribute(int nodeHandle)
    Given a node handle, get the index of the node's first attribute.
    protected int
    Given a node identity, get the index of the node's first attribute.
    int
    getFirstChild(int nodeHandle)
    Given a node handle, get the handle of the node's first child.
    int
    getFirstNamespaceNode(int nodeHandle, boolean inScope)
    Given a node handle, get the index of the node's first namespace node.
    int
    getLastChild(int nodeHandle)
    Given a node handle, get the handle of the node's last child.
    abstract String
    getLocalName(int nodeHandle)
    Given a node handle, return its DOM-style localname.
    Query which DTMManager this DTM is currently being handled by.
    abstract String
    getNamespaceURI(int nodeHandle)
    Given a node handle, return its DOM-style namespace URI (As defined in Namespaces, this is the declared URI which this node's prefix -- or default in lieu thereof -- was mapped to.)
    int
    getNextAttribute(int nodeHandle)
    Given a node handle, advance to the next attribute.
    protected int
    Given a node identity for an attribute, advance to the next attribute.
    int
    getNextNamespaceNode(int baseHandle, int nodeHandle, boolean inScope)
    Given a namespace handle, advance to the next namespace in the same scope (local or local-plus-inherited, as selected by getFirstNamespaceNode)
    protected abstract int
    getNextNodeIdentity(int identity)
    Get the next node identity value in the list, and call the iterator if it hasn't been added yet.
    int
    getNextSibling(int nodeHandle)
    Given a node handle, advance to its next sibling.
    getNode(int nodeHandle)
    Return an DOM node for the given node.
    abstract String
    getNodeName(int nodeHandle)
    Given a node handle, return its DOM-style node name.
    getNodeNameX(int nodeHandle)
    Given a node handle, return the XPath node name.
    short
    getNodeType(int nodeHandle)
    Given a node handle, return its DOM-style node type.
    abstract String
    getNodeValue(int nodeHandle)
    Given a node handle, return its node value.
    int
    getOwnerDocument(int nodeHandle)
    Given a node handle, find the owning document node.
    int
    getParent(int nodeHandle)
    Given a node handle, find its parent node.
    abstract String
    getPrefix(int nodeHandle)
    Given a namespace handle, return the prefix that the namespace decl is mapping.
    int
    getPreviousSibling(int nodeHandle)
    Given a node handle, find its preceeding sibling.
    abstract XString
    getStringValue(int nodeHandle)
    Get the string-value of a node as a String object (see ... for the definition of a node's string-value).
    protected void
    indexNode(int expandedTypeID, int identity)
    Add a node to the element indexes.
    boolean
    isNodeAfter(int nodeHandle1, int nodeHandle2)
    Figure out whether nodeHandle2 should be considered as being later in the document than nodeHandle1, in Document Order as defined by the XPath model.
    final int
    makeNodeHandle(int nodeIdentity)
    Given a node identity, return a node handle.
    final int
    makeNodeIdentity(int nodeHandle)
    Given a node handle, return a node identity.
    protected abstract boolean
    This method should try and build one or more nodes in the table.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.loboevolution.apache.xml.dtm.DTM

    getAxisIterator, getAxisTraverser
  • Field Details

    • ROOTNODE

      public static final int ROOTNODE
      The identity of the root node.
      See Also:
    • m_size

      protected int m_size
      The number of nodes, which is also used to determine the next node index.
    • m_exptype

      protected final SuballocatedIntVector m_exptype
      The expanded names, one array element for each node.
    • m_firstch

      protected final SuballocatedIntVector m_firstch
      First child values, one array element for each node.
    • m_nextsib

      protected final SuballocatedIntVector m_nextsib
      Next sibling values, one array element for each node.
    • m_prevsib

      protected SuballocatedIntVector m_prevsib
      Previous sibling values, one array element for each node.
    • m_parent

      protected final SuballocatedIntVector m_parent
      Previous sibling values, one array element for each node.
    • m_namespaceDeclSets

      protected List<SuballocatedIntVector> m_namespaceDeclSets
      Vector of SuballocatedIntVectors of NS decl sets
    • m_namespaceDeclSetElements

      protected SuballocatedIntVector m_namespaceDeclSetElements
      SuballocatedIntVector of elements at which corresponding namespaceDeclSets were defined
    • m_elemIndexes

      protected int[][][] m_elemIndexes
      These hold indexes to elements based on namespace and local name. The base lookup is the the namespace. The second lookup is the local name, and the last array contains the the first free element at the start, and the list of element handles following.
    • DEFAULT_BLOCKSIZE

      public static final int DEFAULT_BLOCKSIZE
      The default block size of the node arrays
      See Also:
    • DEFAULT_NUMBLOCKS

      public static final int DEFAULT_NUMBLOCKS
      The number of blocks for the node arrays
      See Also:
    • DEFAULT_NUMBLOCKS_SMALL

      public static final int DEFAULT_NUMBLOCKS_SMALL
      The number of blocks used for small documents & RTFs
      See Also:
    • NOTPROCESSED

      protected static final int NOTPROCESSED
      The value to use when the information has not been built yet.
      See Also:
    • m_mgr

      public final DTMManager m_mgr
      The DTM manager who "owns" this DTM.
    • m_mgrDefault

      protected DTMManagerDefault m_mgrDefault
      m_mgr cast to DTMManagerDefault, or null if it isn't an instance (Efficiency hook)
    • m_dtmIdent

      protected final SuballocatedIntVector m_dtmIdent
      The document identity number(s). If we have overflowed the addressing range of the first that was assigned to us, we may add others.
    • m_documentBaseURI

      protected final String m_documentBaseURI
      The base URI for this document.
    • m_expandedNameTable

      protected final ExpandedNameTable m_expandedNameTable
      The table for exandedNameID lookups. This may or may not be the same table as is contained in the DTMManagerDefault.
    • m_indexing

      protected final boolean m_indexing
      true if indexing is turned on.
    • m_traversers

      protected DTMAxisTraverser[] m_traversers
      Stateless axis traversers, lazely built.
  • Constructor Details

    • DTMDefaultBase

      public DTMDefaultBase(DTMManager mgr, Source source, int dtmIdentity, boolean doIndexing)
      Construct a DTMDefaultBase object using the default block size.
      Parameters:
      mgr - The DTMManager who owns this DTM.
      source - The object that is used to specify the construction source.
      dtmIdentity - The DTM identity ID for this DTM.
      doIndexing - true if the caller considers it worth it to use indexing schemes.
    • DTMDefaultBase

      public DTMDefaultBase(DTMManager mgr, Source source, int dtmIdentity, boolean doIndexing, int blocksize, boolean usePrevsib)
      Construct a DTMDefaultBase object from a DOM node.
      Parameters:
      mgr - The DTMManager who owns this DTM.
      source - The object that is used to specify the construction source.
      dtmIdentity - The DTM identity ID for this DTM.
      doIndexing - true if the caller considers it worth it to use indexing schemes.
      blocksize - The block size of the DTM.
      usePrevsib - true if we want to build the previous sibling node array.
  • Method Details

    • ensureSizeOfIndex

      protected void ensureSizeOfIndex(int namespaceID, int LocalNameID)
      Ensure that the size of the element indexes can hold the information.
      Parameters:
      namespaceID - Namespace ID index.
      LocalNameID - Local name ID.
    • indexNode

      protected void indexNode(int expandedTypeID, int identity)
      Add a node to the element indexes. The node will not be added unless it's an element.
      Parameters:
      expandedTypeID - The expanded type ID of the node.
      identity - The node identity index.
    • findGTE

      protected int findGTE(int[] list, int start, int len, int value)
      Find the first index that occurs in the list that is greater than or equal to the given value.
      Parameters:
      list - A list of integers.
      start - The start index to begin the search.
      len - The number of items to search.
      value - Find the slot that has a value that is greater than or identical to this argument.
      Returns:
      The index in the list of the slot that is higher or identical to the identity argument, or -1 if no node is higher or equal.
    • getNextNodeIdentity

      protected abstract int getNextNodeIdentity(int identity)
      Get the next node identity value in the list, and call the iterator if it hasn't been added yet.
      Parameters:
      identity - The node identity (index).
      Returns:
      identity+1, or DTM.NULL.
    • nextNode

      protected abstract boolean nextNode()
      This method should try and build one or more nodes in the table.
      Returns:
      The true if a next node is found or false if there are no more nodes.
    • _type

      protected short _type(int identity)
      Get the simple type ID for the given node identity.
      Parameters:
      identity - The node identity.
      Returns:
      The simple type ID, or DTM.NULL.
    • _exptype

      protected int _exptype(int identity)
      Get the expanded type ID for the given node identity.
      Parameters:
      identity - The node identity.
      Returns:
      The expanded type ID, or DTM.NULL.
    • _level

      protected int _level(int identity)
      Get the level in the tree for the given node identity.
      Parameters:
      identity - The node identity.
      Returns:
      The tree level, or DTM.NULL.
    • _firstch

      protected int _firstch(int identity)
      Get the first child for the given node identity.
      Parameters:
      identity - The node identity.
      Returns:
      The first child identity, or DTM.NULL.
    • _nextsib

      protected int _nextsib(int identity)
      Get the next sibling for the given node identity.
      Parameters:
      identity - The node identity.
      Returns:
      The next sibling identity, or DTM.NULL.
    • _prevsib

      protected int _prevsib(int identity)
      Get the previous sibling for the given node identity.
      Parameters:
      identity - The node identity.
      Returns:
      The previous sibling identity, or DTM.NULL.
    • _parent

      protected int _parent(int identity)
      Get the parent for the given node identity.
      Parameters:
      identity - The node identity.
      Returns:
      The parent identity, or DTM.NULL.
    • dumpNode

      public String dumpNode(int nodeHandle)
      Diagnostics function to dump a single node.

      %REVIEW% KNOWN GLITCH: If you pass it a node index rather than a node handle, it works just fine... but the displayed identity number before the colon is different, which complicates comparing it with nodes printed the other way. We could always OR the DTM ID into the value, to suppress that distinction...

      %REVIEW% This might want to be moved up to DTMDefaultBase, or possibly DTM itself, since it's a useful diagnostic and uses only DTM's public APIs.

    • makeNodeHandle

      public final int makeNodeHandle(int nodeIdentity)
      Given a node identity, return a node handle. If extended addressing has been used (multiple DTM IDs), we need to map the high bits of the identity into the proper DTM ID.

      This has been made FINAL to facilitate inlining, since we do not expect any subclass of DTMDefaultBase to ever change the algorithm. (I don't really like doing so, and would love to have an excuse not to...)

      %REVIEW% Is it worth trying to specialcase small documents? %REVIEW% Should this be exposed at the package/public layers?

      Parameters:
      nodeIdentity - Internal offset to this node's records.
      Returns:
      NodeHandle (external representation of node)
    • makeNodeIdentity

      public final int makeNodeIdentity(int nodeHandle)
      Given a node handle, return a node identity. If extended addressing has been used (multiple DTM IDs), we need to map the high bits of the identity into the proper DTM ID and thence find the proper offset to add to the low bits of the identity

      This has been made FINAL to facilitate inlining, since we do not expect any subclass of DTMDefaultBase to ever change the algorithm. (I don't really like doing so, and would love to have an excuse not to...)

      %OPT% Performance is critical for this operation.

      %REVIEW% Should this be exposed at the package/public layers?

      Parameters:
      nodeHandle - (external representation of node)
      Returns:
      nodeIdentity Internal offset to this node's records.
    • getFirstChild

      public int getFirstChild(int nodeHandle)
      Given a node handle, get the handle of the node's first child.
      Specified by:
      getFirstChild in interface DTM
      Parameters:
      nodeHandle - int Handle of the node.
      Returns:
      int DTM node-number of first child, or DTM.NULL to indicate none exists.
    • getLastChild

      public int getLastChild(int nodeHandle)
      Given a node handle, get the handle of the node's last child.
      Specified by:
      getLastChild in interface DTM
      Parameters:
      nodeHandle - int Handle of the node.
      Returns:
      int Node-number of last child, or DTM.NULL to indicate none exists.
    • getAttributeNode

      public abstract int getAttributeNode(int nodeHandle, String namespaceURI, String name)
      Retrieves an attribute node by local name and namespace URI

      %TBD% Note that we currently have no way to support the DOM's old getAttribute() call, which accesses only the qname.

      Specified by:
      getAttributeNode in interface DTM
      Parameters:
      nodeHandle - Handle of the node upon which to look up this attribute.
      namespaceURI - The namespace URI of the attribute to retrieve, or null.
      name - The local name of the attribute to retrieve.
      Returns:
      The attribute node handle with the specified name ( nodeName) or DTM.NULL if there is no such attribute.
    • getFirstAttribute

      public int getFirstAttribute(int nodeHandle)
      Given a node handle, get the index of the node's first attribute.
      Specified by:
      getFirstAttribute in interface DTM
      Parameters:
      nodeHandle - int Handle of the node.
      Returns:
      Handle of first attribute, or DTM.NULL to indicate none exists.
    • getFirstAttributeIdentity

      protected int getFirstAttributeIdentity(int identity)
      Given a node identity, get the index of the node's first attribute.
      Parameters:
      identity - int identity of the node.
      Returns:
      Identity of first attribute, or DTM.NULL to indicate none exists.
    • getNextSibling

      public int getNextSibling(int nodeHandle)
      Given a node handle, advance to its next sibling.
      Specified by:
      getNextSibling in interface DTM
      Parameters:
      nodeHandle - int Handle of the node.
      Returns:
      int Node-number of next sibling, or DTM.NULL to indicate none exists.
    • getPreviousSibling

      public int getPreviousSibling(int nodeHandle)
      Given a node handle, find its preceeding sibling. WARNING: DTM implementations may be asymmetric; in some, this operation has been resolved by search, and is relatively expensive.
      Specified by:
      getPreviousSibling in interface DTM
      Parameters:
      nodeHandle - the id of the node.
      Returns:
      int Node-number of the previous sib, or DTM.NULL to indicate none exists.
    • getNextAttribute

      public int getNextAttribute(int nodeHandle)
      Given a node handle, advance to the next attribute. If an element, we advance to its first attribute; if an attr, we advance to the next attr of the same element.
      Specified by:
      getNextAttribute in interface DTM
      Parameters:
      nodeHandle - int Handle of the node.
      Returns:
      int DTM node-number of the resolved attr, or DTM.NULL to indicate none exists.
    • getNextAttributeIdentity

      protected int getNextAttributeIdentity(int identity)
      Given a node identity for an attribute, advance to the next attribute.
      Parameters:
      identity - int identity of the attribute node. This must be an attribute node.
      Returns:
      int DTM node-identity of the resolved attr, or DTM.NULL to indicate none exists.
    • declareNamespaceInContext

      protected void declareNamespaceInContext(int elementNodeIndex, int namespaceNodeIndex)
      Build table of namespace declaration locations during DTM construction. Table is a Vector of SuballocatedIntVectors containing the namespace node HANDLES declared at that ID, plus an SuballocatedIntVector of the element node INDEXES at which these declarations appeared.

      NOTE: Since this occurs during model build, nodes will be encountered in doucment order and thus the table will be ordered by element, permitting binary-search as a possible retrieval optimization.

      %REVIEW% Directly managed arrays rather than vectors? %REVIEW% Handles or IDs? Given usage, I think handles.

    • findNamespaceContext

      protected SuballocatedIntVector findNamespaceContext(int elementNodeIndex)
      Retrieve list of namespace declaration locations active at this node. List is an SuballocatedIntVector whose entries are the namespace node HANDLES declared at that ID.

      %REVIEW% Directly managed arrays rather than vectors? %REVIEW% Handles or IDs? Given usage, I think handles.

    • findInSortedSuballocatedIntVector

      protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
      Subroutine: Locate the specified node within m_namespaceDeclSetElements, or the last element which preceeds it in document order

      %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?

      Parameters:
      vector - the vector
      lookfor - the lookfor
      Returns:
      If positive or zero, the index of the found item. If negative, index of the point at which it would have appeared, encoded as -1-index and hence reconvertable by subtracting it from -1. (Encoding because I don't want to recompare the strings but don't want to burn bytes on a datatype to hold a flagged value.)
    • getFirstNamespaceNode

      public int getFirstNamespaceNode(int nodeHandle, boolean inScope)
      Given a node handle, get the index of the node's first namespace node.
      Specified by:
      getFirstNamespaceNode in interface DTM
      Parameters:
      nodeHandle - handle to node, which should probably be an element node, but need not be.
      inScope - true if all namespaces in scope should be returned, false if only the node's own namespace declarations should be returned.
      Returns:
      handle of first namespace, or DTM.NULL to indicate none exists.
    • getNextNamespaceNode

      public int getNextNamespaceNode(int baseHandle, int nodeHandle, boolean inScope)
      Given a namespace handle, advance to the next namespace in the same scope (local or local-plus-inherited, as selected by getFirstNamespaceNode)
      Specified by:
      getNextNamespaceNode in interface DTM
      Parameters:
      baseHandle - handle to original node from where the first child was relative to (needed to return nodes in document order).
      nodeHandle - handle to node which must be of type NAMESPACE_NODE. NEEDSDOC @param inScope
      Returns:
      handle of next namespace, or DTM.NULL to indicate none exists.
    • getParent

      public int getParent(int nodeHandle)
      Given a node handle, find its parent node.
      Specified by:
      getParent in interface DTM
      Parameters:
      nodeHandle - the id of the node.
      Returns:
      int Node handle of parent, or DTM.NULL to indicate none exists.
    • getDocument

      public int getDocument()
      Given a DTM which contains only a single document, find the Node Handle of the Document node. Note that if the DTM is configured so it can contain multiple documents, this call will return the Document currently under construction -- but may return null if it's between documents. Generally, you should use getOwnerDocument(nodeHandle) or getDocumentRoot(nodeHandle) instead.
      Specified by:
      getDocument in interface DTM
      Returns:
      int Node handle of document, or DTM.NULL if a shared DTM can not tell us which Document is currently active.
    • getOwnerDocument

      public int getOwnerDocument(int nodeHandle)
      Given a node handle, find the owning document node. This version mimics the behavior of the DOM call by the same name.
      Specified by:
      getOwnerDocument in interface DTM
      Parameters:
      nodeHandle - the id of the node.
      Returns:
      int Node handle of owning document, or DTM.NULL if the node was a Document.
      See Also:
    • getDocumentRoot

      public int getDocumentRoot(int nodeHandle)
      Given a node handle, find the owning document node.
      Specified by:
      getDocumentRoot in interface DTM
      Parameters:
      nodeHandle - the id of the node.
      Returns:
      int Node handle of owning document, or the node itself if it was a Document. (Note difference from DOM, where getOwnerDocument returns null for the Document node.)
      See Also:
    • getStringValue

      public abstract XString getStringValue(int nodeHandle)
      Get the string-value of a node as a String object (see ... for the definition of a node's string-value).
      Specified by:
      getStringValue in interface DTM
      Parameters:
      nodeHandle - The node ID.
      Returns:
      A string object that represents the string-value of the given node.
    • getExpandedTypeID

      public int getExpandedTypeID(int nodeHandle)
      Given a node handle, return an ID that represents the node's expanded name.
      Specified by:
      getExpandedTypeID in interface DTM
      Parameters:
      nodeHandle - The handle to the node in question.
      Returns:
      the expanded-name id of the node.
    • getExpandedTypeID

      public int getExpandedTypeID(String namespace, String localName, int type)
      Given an expanded name, return an ID. If the expanded-name does not exist in the internal tables, the entry will be created, and the ID will be returned. Any additional nodes that are created that have this expanded name will use this ID.

      NEEDSDOC @param namespace NEEDSDOC @param localName NEEDSDOC @param type

      Specified by:
      getExpandedTypeID in interface DTM
      Returns:
      the expanded-name id of the node.
    • getNodeName

      public abstract String getNodeName(int nodeHandle)
      Given a node handle, return its DOM-style node name. This will include names such as #text or #document.
      Specified by:
      getNodeName in interface DTM
      Parameters:
      nodeHandle - the id of the node.
      Returns:
      String Name of this node, which may be an empty string. %REVIEW% Document when empty string is possible...
    • getNodeNameX

      public String getNodeNameX(int nodeHandle)
      Given a node handle, return the XPath node name. This should be the name as described by the XPath data model, NOT the DOM-style name.
      Specified by:
      getNodeNameX in interface DTM
      Parameters:
      nodeHandle - the id of the node.
      Returns:
      String Name of this node.
    • getLocalName

      public abstract String getLocalName(int nodeHandle)
      Given a node handle, return its DOM-style localname. (As defined in Namespaces, this is the portion of the name after the prefix, if present, or the whole node name if no prefix exists)
      Specified by:
      getLocalName in interface DTM
      Parameters:
      nodeHandle - the id of the node.
      Returns:
      String Local name of this node.
    • getPrefix

      public abstract String getPrefix(int nodeHandle)
      Given a namespace handle, return the prefix that the namespace decl is mapping. Given a node handle, return the prefix used to map to the namespace. (As defined in Namespaces, this is the portion of the name before any colon character).

      %REVIEW% Are you sure you want "" for no prefix?

      Specified by:
      getPrefix in interface DTM
      Parameters:
      nodeHandle - the id of the node.
      Returns:
      String prefix of this node's name, or "" if no explicit namespace prefix was given.
    • getNamespaceURI

      public abstract String getNamespaceURI(int nodeHandle)
      Given a node handle, return its DOM-style namespace URI (As defined in Namespaces, this is the declared URI which this node's prefix -- or default in lieu thereof -- was mapped to.)
      Specified by:
      getNamespaceURI in interface DTM
      Parameters:
      nodeHandle - the id of the node.
      Returns:
      String URI value of this node's namespace, or null if no namespace was resolved.
    • getNodeValue

      public abstract String getNodeValue(int nodeHandle)
      Given a node handle, return its node value. This is mostly as defined by the DOM, but may ignore some conveniences.

      Specified by:
      getNodeValue in interface DTM
      Parameters:
      nodeHandle - The node id.
      Returns:
      String Value of this node, or null if not meaningful for this node type.
    • getNodeType

      public short getNodeType(int nodeHandle)
      Given a node handle, return its DOM-style node type.

      %REVIEW% Generally, returning short is false economy. Return int?

      Specified by:
      getNodeType in interface DTM
      Parameters:
      nodeHandle - The node id.
      Returns:
      int Node type, as per the DOM's Node._NODE constants.
    • getElementById

      public abstract int getElementById(String elementId)
      Returns the Element whose ID is given by elementId. If no such element exists, returns DTM.NULL. Behavior is not defined if more than one element has this ID. Attributes (including those with the name "ID") are not of type ID unless so defined by DTD/Schema information available to the DTM implementation. Implementations that do not know whether attributes are of type ID or not are expected to return DTM.NULL.

      %REVIEW% Presumably IDs are still scoped to a single document, and this operation searches only within a single document, right? Wouldn't want collisions between DTMs in the same process.

      Specified by:
      getElementById in interface DTM
      Parameters:
      elementId - The unique id value for an element.
      Returns:
      The handle of the matching element.
    • isNodeAfter

      public boolean isNodeAfter(int nodeHandle1, int nodeHandle2)
      Figure out whether nodeHandle2 should be considered as being later in the document than nodeHandle1, in Document Order as defined by the XPath model. This may not agree with the ordering defined by other XML applications.

      There are some cases where ordering isn't defined, and neither are the results of this function -- though we'll generally return true.

      %REVIEW% Make sure this does the right thing with attribute nodes!!!

      %REVIEW% Consider renaming for clarity. Perhaps isDocumentOrder(a,b)?

      Specified by:
      isNodeAfter in interface DTM
      Parameters:
      nodeHandle1 - DOM Node to perform position comparison on.
      nodeHandle2 - DOM Node to perform position comparison on.
      Returns:
      false if secondNode comes before firstNode, otherwise return true. You can think of this as (firstNode.documentOrderPosition <= secondNode.documentOrderPosition) .
    • getNode

      public Node getNode(int nodeHandle)
      Return an DOM node for the given node.
      Specified by:
      getNode in interface DTM
      Parameters:
      nodeHandle - The node ID.
      Returns:
      A node representation of the DTM node.
    • error

      protected void error(String msg)
      Simple error for asserts and the like.
      Parameters:
      msg - Error message to report.
    • getManager

      public DTMManager getManager()
      Query which DTMManager this DTM is currently being handled by.

      %REVEW% Should this become part of the base DTM API?

      Returns:
      a DTMManager, or null if this is a "stand-alone" DTM.