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: ContextNodeList.java,v 1.9 2004/02/17 04:32:08 minchau Exp $
018: */
019: package org.apache.xpath.axes;
020:
021: import org.w3c.dom.Node;
022: import org.w3c.dom.traversal.NodeIterator;
023:
024: /**
025: * Classes who implement this interface can be a
026: * <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>,
027: * also refered to here as a <term>context node list</term>.
028: * @xsl.usage advanced
029: */
030: public interface ContextNodeList {
031:
032: /**
033: * Get the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
034: *
035: *
036: * @return The current node, or null.
037: */
038: public Node getCurrentNode();
039:
040: /**
041: * Get the current position, which is one less than
042: * the next nextNode() call will retrieve. i.e. if
043: * you call getCurrentPos() and the return is 0, the next
044: * fetch will take place at index 1.
045: *
046: * @return The position of the
047: * <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>
048: * in the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>.
049: */
050: public int getCurrentPos();
051:
052: /**
053: * Reset the iterator.
054: */
055: public void reset();
056:
057: /**
058: * If setShouldCacheNodes(true) is called, then nodes will
059: * be cached. They are not cached by default.
060: *
061: * @param b true if the nodes should be cached.
062: */
063: public void setShouldCacheNodes(boolean b);
064:
065: /**
066: * If an index is requested, NodeSetDTM will call this method
067: * to run the iterator to the index. By default this sets
068: * m_next to the index. If the index argument is -1, this
069: * signals that the iterator should be run to the end.
070: *
071: * @param index The index to run to, or -1 if the iterator should be run
072: * to the end.
073: */
074: public void runTo(int index);
075:
076: /**
077: * Set the current position in the node set.
078: * @param i Must be a valid index.
079: */
080: public void setCurrentPos(int i);
081:
082: /**
083: * Get the length of the list.
084: *
085: * @return The number of nodes in this node list.
086: */
087: public int size();
088:
089: /**
090: * Tells if this NodeSetDTM is "fresh", in other words, if
091: * the first nextNode() that is called will return the
092: * first node in the set.
093: *
094: * @return true if the iteration of this list has not yet begun.
095: */
096: public boolean isFresh();
097:
098: /**
099: * Get a cloned Iterator that is reset to the start of the iteration.
100: *
101: * @return A clone of this iteration that has been reset.
102: *
103: * @throws CloneNotSupportedException
104: */
105: public NodeIterator cloneWithReset()
106: throws CloneNotSupportedException;
107:
108: /**
109: * Get a clone of this iterator. Be aware that this operation may be
110: * somewhat expensive.
111: *
112: *
113: * @return A clone of this object.
114: *
115: * @throws CloneNotSupportedException
116: */
117: public Object clone() throws CloneNotSupportedException;
118:
119: /**
120: * Get the index of the last node in this list.
121: *
122: *
123: * @return the index of the last node in this list.
124: */
125: public int getLast();
126:
127: /**
128: * Set the index of the last node in this list.
129: *
130: *
131: * @param last the index of the last node in this list.
132: */
133: public void setLast(int last);
134: }
|