dtmdefaultbaseiterators.java

来自「java jdk 1.4的源码」· Java 代码 · 共 1,931 行 · 第 1/4 页

JAVA
1,931
字号
   */  private final class NamespaceChildrenIterator          extends InternalAxisIteratorBase  {    /** The extended type ID being requested. */    private final int _nsType;    /**     * Constructor NamespaceChildrenIterator     *     *     * @param type The extended type ID being requested.     */    public NamespaceChildrenIterator(final int type)    {      _nsType = type;    }    /**     * 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 = NOTPROCESSED;        return resetPosition();      }      return this;    }    /**     * Get the next node in the iteration.     *     * @return The next node handle in the iteration, or END.     */    public int next()    {      for (int node = (NOTPROCESSED == _currentNode)                      ? getFirstChild(_startNode)                      : getNextSibling(_currentNode); node                        != END; node = getNextSibling(node))      {        if (getNamespaceType(node) == _nsType)        {          _currentNode = node;          return returnNode(node);        }      }      return END;    }  }  // end of TypedChildrenIterator    /**   * Iterator that returns the namespace nodes as defined by the XPath data model    * for a given node.   */  private 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)    {      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.   */  private class TypedNamespaceIterator extends NamespaceIterator  {    /** The extended type ID that was requested. */    private final int _nodeType;    /**     * Constructor TypedChildrenIterator     *     *     * @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()    {      for (int node = super.next(); node != END; node = super.next())      {        if (getExpandedTypeID(node) == _nodeType)        {          _currentNode = node;          return returnNode(node);        }      }      return END;    }  }  // end of TypedNamespaceIterator    /**   * Iterator that returns the the root node as defined by the XPath data model    * for a given node.   */  private 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.   */  private 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()    {      for (int node = super.next(); node != END; node = super.next())      {        if (getExpandedTypeID(node) == _nodeType)        {          _currentNode = node;          return returnNode(node);        }      }      return END;    }  }  // end of TypedRootIterator  /**   * Iterator that returns attributes within a given namespace for a node.   */  private 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)    {      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 TypedChildrenIterator  /**   * Iterator that returns all siblings of a given node.   */  private 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)    {      if (_isRestartable)      {        _currentNode = _startNode = 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()    {      return returnNode(_currentNode = getNextSibling(_currentNode));    }  }  // end of FollowingSiblingIterator  /**   * Iterator that returns all following siblings of a given node.   */  private 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()    {      int node;      while ((node = super.next()) != NULL             && getExpandedTypeID(node) != _nodeType){}      return node;    }  }  // end of TypedFollowingSiblingIterator  /**   * Iterator that returns attribute nodes (of what nodes?)   */  private 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)    {      if (_isRestartable)      {        _startNode = node;        _currentNode = getFirstAttribute(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;      _currentNode = getNextAttribute(node);      return returnNode(node);    }  }  // end of AttributeIterator  /**   * Iterator that returns attribute nodes of a given type   */  private 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)

⌨️ 快捷键说明

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