1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*
  17. * $Id: ContextNodeList.java,v 1.9 2004/02/17 04:32:08 minchau Exp $
  18. */
  19. package com.sun.org.apache.xpath.internal.axes;
  20. import org.w3c.dom.Node;
  21. import org.w3c.dom.traversal.NodeIterator;
  22. /**
  23. * Classes who implement this interface can be a
  24. * <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>,
  25. * also refered to here as a <term>context node list</term>.
  26. * @xsl.usage advanced
  27. */
  28. public interface ContextNodeList
  29. {
  30. /**
  31. * Get the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
  32. *
  33. *
  34. * @return The current node, or null.
  35. */
  36. public Node getCurrentNode();
  37. /**
  38. * Get the current position, which is one less than
  39. * the next nextNode() call will retrieve. i.e. if
  40. * you call getCurrentPos() and the return is 0, the next
  41. * fetch will take place at index 1.
  42. *
  43. * @return The position of the
  44. * <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>
  45. * in the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>.
  46. */
  47. public int getCurrentPos();
  48. /**
  49. * Reset the iterator.
  50. */
  51. public void reset();
  52. /**
  53. * If setShouldCacheNodes(true) is called, then nodes will
  54. * be cached. They are not cached by default.
  55. *
  56. * @param b true if the nodes should be cached.
  57. */
  58. public void setShouldCacheNodes(boolean b);
  59. /**
  60. * If an index is requested, NodeSetDTM will call this method
  61. * to run the iterator to the index. By default this sets
  62. * m_next to the index. If the index argument is -1, this
  63. * signals that the iterator should be run to the end.
  64. *
  65. * @param index The index to run to, or -1 if the iterator should be run
  66. * to the end.
  67. */
  68. public void runTo(int index);
  69. /**
  70. * Set the current position in the node set.
  71. * @param i Must be a valid index.
  72. */
  73. public void setCurrentPos(int i);
  74. /**
  75. * Get the length of the list.
  76. *
  77. * @return The number of nodes in this node list.
  78. */
  79. public int size();
  80. /**
  81. * Tells if this NodeSetDTM is "fresh", in other words, if
  82. * the first nextNode() that is called will return the
  83. * first node in the set.
  84. *
  85. * @return true if the iteration of this list has not yet begun.
  86. */
  87. public boolean isFresh();
  88. /**
  89. * Get a cloned Iterator that is reset to the start of the iteration.
  90. *
  91. * @return A clone of this iteration that has been reset.
  92. *
  93. * @throws CloneNotSupportedException
  94. */
  95. public NodeIterator cloneWithReset() throws CloneNotSupportedException;
  96. /**
  97. * Get a clone of this iterator. Be aware that this operation may be
  98. * somewhat expensive.
  99. *
  100. *
  101. * @return A clone of this object.
  102. *
  103. * @throws CloneNotSupportedException
  104. */
  105. public Object clone() throws CloneNotSupportedException;
  106. /**
  107. * Get the index of the last node in this list.
  108. *
  109. *
  110. * @return the index of the last node in this list.
  111. */
  112. public int getLast();
  113. /**
  114. * Set the index of the last node in this list.
  115. *
  116. *
  117. * @param last the index of the last node in this list.
  118. */
  119. public void setLast(int last);
  120. }