19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one 39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file 49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information 59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file 69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the "License"); 79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License. 89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at 99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software 139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and 169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License. 179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id: ContextNodeList.java 468655 2006-10-28 07:12:06Z minchau $ 209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xpath.axes; 229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.w3c.dom.Node; 249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.w3c.dom.traversal.NodeIterator; 259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/** 279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Classes who implement this interface can be a 289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>, 299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * also refered to here as a <term>context node list</term>. 309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @xsl.usage advanced 319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic interface ContextNodeList 339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{ 349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>. 379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The current node, or null. 409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public Node getCurrentNode(); 429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the current position, which is one less than 459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the next nextNode() call will retrieve. i.e. if 469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you call getCurrentPos() and the return is 0, the next 479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * fetch will take place at index 1. 489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The position of the 509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a> 519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * in the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>. 529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public int getCurrentPos(); 549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Reset the iterator. 579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void reset(); 599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If setShouldCacheNodes(true) is called, then nodes will 629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * be cached. They are not cached by default. 639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param b true if the nodes should be cached. 659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setShouldCacheNodes(boolean b); 679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If an index is requested, NodeSetDTM will call this method 709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to run the iterator to the index. By default this sets 719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * m_next to the index. If the index argument is -1, this 729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * signals that the iterator should be run to the end. 739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param index The index to run to, or -1 if the iterator should be run 759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to the end. 769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void runTo(int index); 789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set the current position in the node set. 819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param i Must be a valid index. 829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setCurrentPos(int i); 849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the length of the list. 879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The number of nodes in this node list. 899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public int size(); 919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Tells if this NodeSetDTM is "fresh", in other words, if 949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the first nextNode() that is called will return the 959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * first node in the set. 969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return true if the iteration of this list has not yet begun. 989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public boolean isFresh(); 1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get a cloned Iterator that is reset to the start of the iteration. 1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A clone of this iteration that has been reset. 1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws CloneNotSupportedException 1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public NodeIterator cloneWithReset() throws CloneNotSupportedException; 1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get a clone of this iterator. Be aware that this operation may be 1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * somewhat expensive. 1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A clone of this object. 1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws CloneNotSupportedException 1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public Object clone() throws CloneNotSupportedException; 1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the index of the last node in this list. 1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the index of the last node in this list. 1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public int getLast(); 1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set the index of the last node in this list. 1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param last the index of the last node in this list. 1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setLast(int last); 1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson} 137