001: /*
002: * Copyright 1999-2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: /*
017: * $Id: DTMAxisIterator.java,v 1.7 2004/02/16 23:03:44 minchau Exp $
018: */
019: package org.apache.xml.dtm;
020:
021: /**
022: * This class iterates over a single XPath Axis, and returns node handles.
023: */
024: public interface DTMAxisIterator extends Cloneable {
025:
026: /** Specifies the end of the iteration, and is the same as DTM.NULL. */
027: public static final int END = DTM.NULL;
028:
029: /**
030: * Get the next node in the iteration.
031: *
032: * @return The next node handle in the iteration, or END.
033: */
034: public int next();
035:
036: /**
037: * Resets the iterator to the last start node.
038: *
039: * @return A DTMAxisIterator, which may or may not be the same as this
040: * iterator.
041: */
042: public DTMAxisIterator reset();
043:
044: /**
045: * @return the number of nodes in this iterator. This may be an expensive
046: * operation when called the first time.
047: */
048: public int getLast();
049:
050: /**
051: * @return The position of the current node in the set, as defined by XPath.
052: */
053: public int getPosition();
054:
055: /**
056: * Remembers the current node for the next call to gotoMark().
057: */
058: public void setMark();
059:
060: /**
061: * Restores the current node remembered by setMark().
062: */
063: public void gotoMark();
064:
065: /**
066: * Set start to END should 'close' the iterator,
067: * i.e. subsequent call to next() should return END.
068: *
069: * @param node Sets the root of the iteration.
070: *
071: * @return A DTMAxisIterator set to the start of the iteration.
072: */
073: public DTMAxisIterator setStartNode(int node);
074:
075: /**
076: * Get start to END should 'close' the iterator,
077: * i.e. subsequent call to next() should return END.
078: *
079: * @return The root node of the iteration.
080: */
081: public int getStartNode();
082:
083: /**
084: * @return true if this iterator has a reversed axis, else false.
085: */
086: public boolean isReverse();
087:
088: /**
089: * @return a deep copy of this iterator. The clone should not be reset
090: * from its current position.
091: */
092: public DTMAxisIterator cloneIterator();
093:
094: /**
095: * Set if restartable.
096: */
097: public void setRestartable(boolean isRestartable);
098:
099: /**
100: * Return the node at the given position.
101: *
102: * @param position The position
103: * @return The node at the given position.
104: */
105: public int getNodeByPosition(int position);
106: }
|