dtmdefaultbaseiterators.java

来自「JAVA 所有包」· Java 代码 · 共 2,195 行 · 第 1/4 页

JAVA
2,195
字号
      return this;    }    /**     * Get the next node in the iteration.     *     * @return The next node handle in the iteration, or END.     */    public int next()    {      if (_currentNode != DTM.NULL) {        for (int node = (NOTPROCESSED == _currentNode)                                  ? _firstch(makeNodeIdentity(_startNode))                                  : _nextsib(_currentNode);             node != END;             node = _nextsib(node)) {          if (m_expandedNameTable.getNamespaceID(_exptype(node)) == _nsType) {            _currentNode = node;            return returnNode(node);          }        }      }      return END;    }  }  // end of NamespaceChildrenIterator    /**   * Iterator that returns the namespace nodes as defined by the XPath data model    * for a given node.   */  public class NamespaceIterator          extends InternalAxisIteratorBase  {    /**     * Constructor NamespaceAttributeIterator     */    public NamespaceIterator()    {      super();    }    /**     * Set start to END should 'close' the iterator,     * i.e. subsequent call to next() should return END.     *     * @param node Sets the root of the iteration.     *     * @return A DTMAxisIterator set to the start of the iteration.     */    public DTMAxisIterator setStartNode(int node)    {//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily      if (node == DTMDefaultBase.ROOTNODE)        node = getDocument();      if (_isRestartable)      {        _startNode = node;        _currentNode = getFirstNamespaceNode(node, true);        return resetPosition();      }      return this;    }    /**     * Get the next node in the iteration.     *     * @return The next node handle in the iteration, or END.     */    public int next()    {      int node = _currentNode;      if (DTM.NULL != node)        _currentNode = getNextNamespaceNode(_startNode, node, true);      return returnNode(node);    }  }  // end of NamespaceIterator    /**   * Iterator that returns the namespace nodes as defined by the XPath data model    * for a given node, filtered by extended type ID.   */  public class TypedNamespaceIterator extends NamespaceIterator  {    /** The extended type ID that was requested. */    private final int _nodeType;    /**     * Constructor TypedNamespaceIterator     *     *     * @param nodeType The extended type ID being requested.     */    public TypedNamespaceIterator(int nodeType)    {      super();      _nodeType = nodeType;    }    /**     * Get the next node in the iteration.     *     * @return The next node handle in the iteration, or END.     */    public int next()    {    	int node;      for (node = _currentNode;           node != END;           node = getNextNamespaceNode(_startNode, node, true)) {        if (getExpandedTypeID(node) == _nodeType            || getNodeType(node) == _nodeType            || getNamespaceType(node) == _nodeType) {          _currentNode = node;          return returnNode(node);        }      }      return (_currentNode =END);    }  }  // end of TypedNamespaceIterator    /**   * Iterator that returns the the root node as defined by the XPath data model    * for a given node.   */  public class RootIterator          extends InternalAxisIteratorBase  {    /**     * Constructor RootIterator     */    public RootIterator()    {      super();    }    /**     * Set start to END should 'close' the iterator,     * i.e. subsequent call to next() should return END.     *     * @param node Sets the root of the iteration.     *     * @return A DTMAxisIterator set to the start of the iteration.     */    public DTMAxisIterator setStartNode(int node)    {      if (_isRestartable)      {        _startNode = getDocumentRoot(node);        _currentNode = NULL;        return resetPosition();      }      return this;    }    /**     * Get the next node in the iteration.     *     * @return The next node handle in the iteration, or END.     */    public int next()    {      if(_startNode == _currentNode)        return NULL;      _currentNode = _startNode;      return returnNode(_startNode);    }  }  // end of RootIterator    /**   * Iterator that returns the namespace nodes as defined by the XPath data model    * for a given node, filtered by extended type ID.   */  public class TypedRootIterator extends RootIterator  {    /** The extended type ID that was requested. */    private final int _nodeType;    /**     * Constructor TypedRootIterator     *     * @param nodeType The extended type ID being requested.     */    public TypedRootIterator(int nodeType)    {      super();      _nodeType = nodeType;    }    /**     * Get the next node in the iteration.     *     * @return The next node handle in the iteration, or END.     */    public int next()    {    	if(_startNode == _currentNode)        return NULL;      int nodeType = _nodeType;      int node = _startNode;      int expType = getExpandedTypeID(node);      _currentNode = node;      if (nodeType >= DTM.NTYPES) {        if (nodeType == expType) {          return returnNode(node);        }      } else {        if (expType < DTM.NTYPES) {          if (expType == nodeType) {            return returnNode(node);          }        } else {          if (m_expandedNameTable.getType(expType) == nodeType) {            return returnNode(node);          }        }      }      return END;    }  }  // end of TypedRootIterator  /**   * Iterator that returns attributes within a given namespace for a node.   */  public final class NamespaceAttributeIterator          extends InternalAxisIteratorBase  {    /** The extended type ID being requested. */    private final int _nsType;    /**     * Constructor NamespaceAttributeIterator     *     *     * @param nsType The extended type ID being requested.     */    public NamespaceAttributeIterator(int nsType)    {      super();      _nsType = nsType;    }    /**     * Set start to END should 'close' the iterator,     * i.e. subsequent call to next() should return END.     *     * @param node Sets the root of the iteration.     *     * @return A DTMAxisIterator set to the start of the iteration.     */    public DTMAxisIterator setStartNode(int node)    {//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily      if (node == DTMDefaultBase.ROOTNODE)        node = getDocument();      if (_isRestartable)      {        _startNode = node;        _currentNode = getFirstNamespaceNode(node, false);        return resetPosition();      }      return this;    }    /**     * Get the next node in the iteration.     *     * @return The next node handle in the iteration, or END.     */    public int next()    {      int node = _currentNode;      if (DTM.NULL != node)        _currentNode = getNextNamespaceNode(_startNode, node, false);      return returnNode(node);    }  }  // end of NamespaceAttributeIterator  /**   * Iterator that returns all siblings of a given node.   */  public class FollowingSiblingIterator extends InternalAxisIteratorBase  {    /**     * Set start to END should 'close' the iterator,     * i.e. subsequent call to next() should return END.     *     * @param node Sets the root of the iteration.     *     * @return A DTMAxisIterator set to the start of the iteration.     */    public DTMAxisIterator setStartNode(int node)    {//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily      if (node == DTMDefaultBase.ROOTNODE)        node = getDocument();      if (_isRestartable)      {        _startNode = node;        _currentNode = makeNodeIdentity(node);        return resetPosition();      }      return this;    }    /**     * Get the next node in the iteration.     *     * @return The next node handle in the iteration, or END.     */    public int next()    {      _currentNode = (_currentNode == DTM.NULL) ? DTM.NULL                                                : _nextsib(_currentNode);      return returnNode(makeNodeHandle(_currentNode));    }  }  // end of FollowingSiblingIterator  /**   * Iterator that returns all following siblings of a given node.   */  public final class TypedFollowingSiblingIterator          extends FollowingSiblingIterator  {    /** The extended type ID that was requested. */    private final int _nodeType;    /**     * Constructor TypedFollowingSiblingIterator     *     *     * @param type The extended type ID being requested.     */    public TypedFollowingSiblingIterator(int type)    {      _nodeType = type;    }    /**     * Get the next node in the iteration.     *     * @return The next node handle in the iteration, or END.     */    public int next()    {      if (_currentNode == DTM.NULL) {        return DTM.NULL;      }      int node = _currentNode;      int eType;      int nodeType = _nodeType;      if (nodeType >= DTM.NTYPES) {        do {          node = _nextsib(node);        } while (node != DTM.NULL && _exptype(node) != nodeType);      } else {        while ((node = _nextsib(node)) != DTM.NULL) {          eType = _exptype(node);          if (eType < DTM.NTYPES) {            if (eType == nodeType) {              break;            }          } else if (m_expandedNameTable.getType(eType) == nodeType) {            break;          }        }      }      _currentNode = node;      return (_currentNode == DTM.NULL)                      ? DTM.NULL                      : returnNode(makeNodeHandle(_currentNode));    }  }  // end of TypedFollowingSiblingIterator  /**   * Iterator that returns attribute nodes (of what nodes?)   */  public final class AttributeIterator extends InternalAxisIteratorBase  {    // assumes caller will pass element nodes    /**     * Set start to END should 'close' the iterator,     * i.e. subsequent call to next() should return END.     *     * @param node Sets the root of the iteration.     *     * @return A DTMAxisIterator set to the start of the iteration.     */    public DTMAxisIterator setStartNode(int node)    {//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily      if (node == DTMDefaultBase.ROOTNODE)        node = getDocument();      if (_isRestartable)      {        _startNode = node;        _currentNode = getFirstAttributeIdentity(makeNodeIdentity(node));        return resetPosition();      }      return this;    }    /**     * Get the next node in the iteration.     *     * @return The next node handle in the iteration, or END.     */    public int next()    {      final int node = _currentNode;      if (node != NULL) {        _currentNode = getNextAttributeIdentity(node);        return returnNode(makeNodeHandle(node));      }      return NULL;    }  }  // end of AttributeIterator  /**   * Iterator that returns attribute nodes of a given type   */  public final class TypedAttributeIterator extends InternalAxisIteratorBase  {    /** The extended type ID that was requested. */    private final int _nodeType;    /**     * Constructor TypedAttributeIterator     *     *     * @param nodeType The extended type ID that is requested.     */    public TypedAttributeIterator(int nodeType)    {      _nodeType = nodeType;    }    // assumes caller will pass element nodes    /**     * Set start to END should 'close' the iterator,     * i.e. subsequent call to next() should return END.     *     * @param node Sets the root of the iteration.     *     * @return A DTMAxisIterator set to the start of the iteration.     */    public DTMAxisIterator setStartNode(int node)    {      if (_isRestartable)      {        _startNode = node;        _currentNode = getTypedAttribute(node, _nodeType);        return resetPosition();      }      return this;    }    /**     * Get the next node in the iteration.     *     * @return The next node handle in the iteration, or END.     */    public int next()    {      final int node = _currentNode;      // singleton iterator, since there can only be one attribute of       // a given type.      _currentNode = NULL;      return returnNode(node);    }  }  // end of TypedAttributeIterator  /**   * Iterator that returns preceding siblings of a given node   */  public class PrecedingSiblingIterator extends InternalAxisIteratorBase  {    /**     * The node identity of _startNode for this iterator     */    protected int _startNodeID;    /**     * True if this iterator has a reversed axis.     *     * @return true.     */    public boolean isReverse()    {      return true;    }    /**

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?