1 /* 2 * Copyright the original author or authors. 3 * 4 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.mozilla.org/MPL/MPL-1.1.html 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import org.as2lib.core.BasicInterface; 18 19 /** 20 * {@code Iterator} is used to iterate over data holders. 21 * 22 * <p>An iterator is quite simple to use. There is one method to check whether there 23 * are more elements left to iterate over {@link #hasNext}, one method to get the 24 * next element {@link #next} and one to remove the current element {@link #remove}. 25 * 26 * <p>Example: 27 * <code> 28 * var iterator:Iterator = new MyIterator("value1", "value2", "value3"); 29 * while (iterator.hasNext()) { 30 * trace(iterator.next()); 31 * } 32 * </code> 33 * 34 * <p>Output: 35 * <pre> 36 * value1 37 * value2 38 * value3 39 * </pre> 40 * 41 * @author Simon Wacker 42 * @author Michael Herrmann 43 */ 44 interface org.as2lib.data.holder.Iterator extends BasicInterface { 45 46 /** 47 * Returns whether there is another element to iterate over. 48 * 49 * @return {@code true} if there is at least one element left to iterate 50 * over 51 */ 52 public function hasNext(Void):Boolean; 53 54 /** 55 * Returns the next element. 56 * 57 * @return the next element 58 * @throws org.as2lib.data.holder.NoSuchElementException if there is no next element 59 */ 60 public function next(Void); 61 62 /** 63 * Removes the currently selected element from this iterator and from the data holder 64 * this iterator iterates over. 65 * 66 * @throws org.as2lib.env.except.IllegalStateException if you try to remove an element 67 * when none is selected 68 * @throws org.as2lib.env.except.UnsupportedOperationException if this method is not 69 * supported by the concrete implementation of this interface 70 */ 71 public function remove(Void):Void; 72 73 }