001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package java.util;
019:
020: /**
021: * An ListIterator is used to sequence over a List of objects. ListIterator can
022: * move backwards or forwards through the List.
023: */
024: public interface ListIterator<E> extends Iterator<E> {
025:
026: /**
027: * Inserts the specified object into the list between <code>next</code>
028: * and <code>previous</code>. The object inserted will be the previous
029: * object.
030: *
031: * @param object
032: * the object to insert
033: *
034: * @exception UnsupportedOperationException
035: * when adding is not supported by the list being iterated
036: * @exception ClassCastException
037: * when the class of the object is inappropriate for the list
038: * @exception IllegalArgumentException
039: * when the object cannot be added to the list
040: */
041: void add(E object);
042:
043: /**
044: * Answers if there are more elements to iterate.
045: *
046: * @return true if there are more elements, false otherwise
047: *
048: * @see #next
049: */
050: public boolean hasNext();
051:
052: /**
053: * Answers if there are previous elements to iterate.
054: *
055: * @return true if there are previous elements, false otherwise
056: *
057: * @see #previous
058: */
059: public boolean hasPrevious();
060:
061: /**
062: * Answers the next object in the iteration.
063: *
064: * @return the next object
065: *
066: * @exception NoSuchElementException
067: * when there are no more elements
068: *
069: * @see #hasNext
070: */
071: public E next();
072:
073: /**
074: * Answers the index of the next object in the iteration.
075: *
076: * @return the index of the next object
077: *
078: * @exception NoSuchElementException
079: * when there are no more elements
080: *
081: * @see #next
082: */
083: public int nextIndex();
084:
085: /**
086: * Answers the previous object in the iteration.
087: *
088: * @return the previous object
089: *
090: * @exception NoSuchElementException
091: * when there are no previous elements
092: *
093: * @see #hasPrevious
094: */
095: public E previous();
096:
097: /**
098: * Answers the index of the previous object in the iteration.
099: *
100: * @return the index of the previous object
101: *
102: * @exception NoSuchElementException
103: * when there are no previous elements
104: *
105: * @see #previous
106: */
107: public int previousIndex();
108:
109: /**
110: * Removes the last object returned by <code>next</code> or
111: * <code>previous</code> from the list.
112: *
113: * @exception UnsupportedOperationException
114: * when removing is not supported by the list being iterated
115: * @exception IllegalStateException
116: * when <code>next</code> or <code>previous</code> have
117: * not been called, or <code>remove</code> or
118: * <code>add</code> have already been called after the last
119: * call to <code>next</code> or <code>previous</code>
120: */
121: public void remove();
122:
123: /**
124: * Replaces the last object returned by <code>next</code> or
125: * <code>previous</code> with the specified object.
126: *
127: * @param object
128: * the object to add
129: *
130: * @exception UnsupportedOperationException
131: * when adding is not supported by the list being iterated
132: * @exception ClassCastException
133: * when the class of the object is inappropriate for the list
134: * @exception IllegalArgumentException
135: * when the object cannot be added to the list
136: * @exception IllegalStateException
137: * when <code>next</code> or <code>previous</code> have
138: * not been called, or <code>remove</code> or
139: * <code>add</code> have already been called after the last
140: * call to <code>next</code> or <code>previous</code>
141: */
142: void set(E object);
143: }
|