001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 /*
019 * $Id: ContextNodeList.java 468655 2006-10-28 07:12:06Z minchau $
020 */
021 package org.apache.xpath.axes;
022
023 import org.w3c.dom.Node;
024 import org.w3c.dom.traversal.NodeIterator;
025
026 /**
027 * Classes who implement this interface can be a
028 * <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>,
029 * also refered to here as a <term>context node list</term>.
030 * @xsl.usage advanced
031 */
032 public interface ContextNodeList
033 {
034
035 /**
036 * Get the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
037 *
038 *
039 * @return The current node, or null.
040 */
041 public Node getCurrentNode();
042
043 /**
044 * Get the current position, which is one less than
045 * the next nextNode() call will retrieve. i.e. if
046 * you call getCurrentPos() and the return is 0, the next
047 * fetch will take place at index 1.
048 *
049 * @return The position of the
050 * <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>
051 * in the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>.
052 */
053 public int getCurrentPos();
054
055 /**
056 * Reset the iterator.
057 */
058 public void reset();
059
060 /**
061 * If setShouldCacheNodes(true) is called, then nodes will
062 * be cached. They are not cached by default.
063 *
064 * @param b true if the nodes should be cached.
065 */
066 public void setShouldCacheNodes(boolean b);
067
068 /**
069 * If an index is requested, NodeSetDTM will call this method
070 * to run the iterator to the index. By default this sets
071 * m_next to the index. If the index argument is -1, this
072 * signals that the iterator should be run to the end.
073 *
074 * @param index The index to run to, or -1 if the iterator should be run
075 * to the end.
076 */
077 public void runTo(int index);
078
079 /**
080 * Set the current position in the node set.
081 * @param i Must be a valid index.
082 */
083 public void setCurrentPos(int i);
084
085 /**
086 * Get the length of the list.
087 *
088 * @return The number of nodes in this node list.
089 */
090 public int size();
091
092 /**
093 * Tells if this NodeSetDTM is "fresh", in other words, if
094 * the first nextNode() that is called will return the
095 * first node in the set.
096 *
097 * @return true if the iteration of this list has not yet begun.
098 */
099 public boolean isFresh();
100
101 /**
102 * Get a cloned Iterator that is reset to the start of the iteration.
103 *
104 * @return A clone of this iteration that has been reset.
105 *
106 * @throws CloneNotSupportedException
107 */
108 public NodeIterator cloneWithReset() throws CloneNotSupportedException;
109
110 /**
111 * Get a clone of this iterator. Be aware that this operation may be
112 * somewhat expensive.
113 *
114 *
115 * @return A clone of this object.
116 *
117 * @throws CloneNotSupportedException
118 */
119 public Object clone() throws CloneNotSupportedException;
120
121 /**
122 * Get the index of the last node in this list.
123 *
124 *
125 * @return the index of the last node in this list.
126 */
127 public int getLast();
128
129 /**
130 * Set the index of the last node in this list.
131 *
132 *
133 * @param last the index of the last node in this list.
134 */
135 public void setLast(int last);
136 }