1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Licensed to the Apache Software Foundation (ASF) under one or more 7 * contributor license agreements. See the NOTICE file distributed with 8 * this work for additional information regarding copyright ownership. 9 * The ASF licenses this file to You under the Apache License, Version 2.0 10 * (the "License"); you may not use this file except in compliance with 11 * the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22 package com.sun.org.apache.xpath.internal.axes; 23 24 import org.w3c.dom.Node; 25 import org.w3c.dom.traversal.NodeIterator; 26 27 /** 28 * Classes who implement this interface can be a 29 * <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>, 30 * also refered to here as a <term>context node list</term>. 31 * @xsl.usage advanced 32 */ 33 public interface ContextNodeList 34 { 35 36 /** 37 * Get the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>. 38 * 39 * 40 * @return The current node, or null. 41 */ getCurrentNode()42 public Node getCurrentNode(); 43 44 /** 45 * Get the current position, which is one less than 46 * the next nextNode() call will retrieve. i.e. if 47 * you call getCurrentPos() and the return is 0, the next 48 * fetch will take place at index 1. 49 * 50 * @return The position of the 51 * <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a> 52 * in the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>. 53 */ getCurrentPos()54 public int getCurrentPos(); 55 56 /** 57 * Reset the iterator. 58 */ reset()59 public void reset(); 60 61 /** 62 * If setShouldCacheNodes(true) is called, then nodes will 63 * be cached. They are not cached by default. 64 * 65 * @param b true if the nodes should be cached. 66 */ setShouldCacheNodes(boolean b)67 public void setShouldCacheNodes(boolean b); 68 69 /** 70 * If an index is requested, NodeSetDTM will call this method 71 * to run the iterator to the index. By default this sets 72 * m_next to the index. If the index argument is -1, this 73 * signals that the iterator should be run to the end. 74 * 75 * @param index The index to run to, or -1 if the iterator should be run 76 * to the end. 77 */ runTo(int index)78 public void runTo(int index); 79 80 /** 81 * Set the current position in the node set. 82 * @param i Must be a valid index. 83 */ setCurrentPos(int i)84 public void setCurrentPos(int i); 85 86 /** 87 * Get the length of the list. 88 * 89 * @return The number of nodes in this node list. 90 */ size()91 public int size(); 92 93 /** 94 * Tells if this NodeSetDTM is "fresh", in other words, if 95 * the first nextNode() that is called will return the 96 * first node in the set. 97 * 98 * @return true if the iteration of this list has not yet begun. 99 */ isFresh()100 public boolean isFresh(); 101 102 /** 103 * Get a cloned Iterator that is reset to the start of the iteration. 104 * 105 * @return A clone of this iteration that has been reset. 106 * 107 * @throws CloneNotSupportedException 108 */ cloneWithReset()109 public NodeIterator cloneWithReset() throws CloneNotSupportedException; 110 111 /** 112 * Get a clone of this iterator. Be aware that this operation may be 113 * somewhat expensive. 114 * 115 * 116 * @return A clone of this object. 117 * 118 * @throws CloneNotSupportedException 119 */ clone()120 public Object clone() throws CloneNotSupportedException; 121 122 /** 123 * Get the index of the last node in this list. 124 * 125 * 126 * @return the index of the last node in this list. 127 */ getLast()128 public int getLast(); 129 130 /** 131 * Set the index of the last node in this list. 132 * 133 * 134 * @param last the index of the last node in this list. 135 */ setLast(int last)136 public void setLast(int last); 137 } 138