1/* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18/* 19 * $Id: ContextNodeList.java 468655 2006-10-28 07:12:06Z minchau $ 20 */ 21package org.apache.xpath.axes; 22 23import org.w3c.dom.Node; 24import org.w3c.dom.traversal.NodeIterator; 25 26/** 27 * Classes who implement this interface can be a 28 * <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>, 29 * also refered to here as a <term>context node list</term>. 30 * @xsl.usage advanced 31 */ 32public interface ContextNodeList 33{ 34 35 /** 36 * Get the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>. 37 * 38 * 39 * @return The current node, or null. 40 */ 41 public Node getCurrentNode(); 42 43 /** 44 * Get the current position, which is one less than 45 * the next nextNode() call will retrieve. i.e. if 46 * you call getCurrentPos() and the return is 0, the next 47 * fetch will take place at index 1. 48 * 49 * @return The position of the 50 * <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a> 51 * in the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>. 52 */ 53 public int getCurrentPos(); 54 55 /** 56 * Reset the iterator. 57 */ 58 public void reset(); 59 60 /** 61 * If setShouldCacheNodes(true) is called, then nodes will 62 * be cached. They are not cached by default. 63 * 64 * @param b true if the nodes should be cached. 65 */ 66 public void setShouldCacheNodes(boolean b); 67 68 /** 69 * If an index is requested, NodeSetDTM will call this method 70 * to run the iterator to the index. By default this sets 71 * m_next to the index. If the index argument is -1, this 72 * signals that the iterator should be run to the end. 73 * 74 * @param index The index to run to, or -1 if the iterator should be run 75 * to the end. 76 */ 77 public void runTo(int index); 78 79 /** 80 * Set the current position in the node set. 81 * @param i Must be a valid index. 82 */ 83 public void setCurrentPos(int i); 84 85 /** 86 * Get the length of the list. 87 * 88 * @return The number of nodes in this node list. 89 */ 90 public int size(); 91 92 /** 93 * Tells if this NodeSetDTM is "fresh", in other words, if 94 * the first nextNode() that is called will return the 95 * first node in the set. 96 * 97 * @return true if the iteration of this list has not yet begun. 98 */ 99 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} 137