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: DTMAxisIterator.java,v 1.7 2004/02/16 23:03:44 minchau Exp $
  18. */
  19. package com.sun.org.apache.xml.internal.dtm;
  20. /**
  21. * This class iterates over a single XPath Axis, and returns node handles.
  22. */
  23. public interface DTMAxisIterator extends Cloneable
  24. {
  25. /** Specifies the end of the iteration, and is the same as DTM.NULL. */
  26. public static final int END = DTM.NULL;
  27. /**
  28. * Get the next node in the iteration.
  29. *
  30. * @return The next node handle in the iteration, or END.
  31. */
  32. public int next();
  33. /**
  34. * Resets the iterator to the last start node.
  35. *
  36. * @return A DTMAxisIterator, which may or may not be the same as this
  37. * iterator.
  38. */
  39. public DTMAxisIterator reset();
  40. /**
  41. * @return the number of nodes in this iterator. This may be an expensive
  42. * operation when called the first time.
  43. */
  44. public int getLast();
  45. /**
  46. * @return The position of the current node in the set, as defined by XPath.
  47. */
  48. public int getPosition();
  49. /**
  50. * Remembers the current node for the next call to gotoMark().
  51. */
  52. public void setMark();
  53. /**
  54. * Restores the current node remembered by setMark().
  55. */
  56. public void gotoMark();
  57. /**
  58. * Set start to END should 'close' the iterator,
  59. * i.e. subsequent call to next() should return END.
  60. *
  61. * @param node Sets the root of the iteration.
  62. *
  63. * @return A DTMAxisIterator set to the start of the iteration.
  64. */
  65. public DTMAxisIterator setStartNode(int node);
  66. /**
  67. * Get start to END should 'close' the iterator,
  68. * i.e. subsequent call to next() should return END.
  69. *
  70. * @return The root node of the iteration.
  71. */
  72. public int getStartNode();
  73. /**
  74. * @return true if this iterator has a reversed axis, else false.
  75. */
  76. public boolean isReverse();
  77. /**
  78. * @return a deep copy of this iterator. The clone should not be reset
  79. * from its current position.
  80. */
  81. public DTMAxisIterator cloneIterator();
  82. /**
  83. * Set if restartable.
  84. */
  85. public void setRestartable(boolean isRestartable);
  86. /**
  87. * Return the node at the given position.
  88. *
  89. * @param position The position
  90. * @return The node at the given position.
  91. */
  92. public int getNodeByPosition(int position);
  93. }