1 package net.sf.saxon.om; 2 import net.sf.saxon.expr.LastPositionFinder; 3 import net.sf.saxon.value.SequenceExtent; 4 import net.sf.saxon.value.Value; 5 6 import java.util.List ; 7 8 12 13 public final class ListIterator 14 implements AxisIterator, LastPositionFinder, LookaheadIterator, GroundedIterator { 15 16 int index=0; 17 int length; 18 Item current = null; 19 List list = null; 20 21 25 26 public ListIterator(List list) { 27 index = 0; 28 this.list = list; 29 this.length = list.size(); 30 } 31 32 public boolean hasNext() { 33 return index<length; 34 } 35 36 public Item next() { 37 if (index >= length) { 38 current = null; 39 index = -1; 40 length = -1; 41 return null; 42 } 43 current = (Item)list.get(index++); 44 return current; 45 } 46 47 public Item current() { 48 return current; 49 } 50 51 public int position() { 52 return index; 53 } 54 55 public int getLastPosition() { 56 return length; 57 } 58 59 public SequenceIterator getAnother() { 60 return new ListIterator(list); 61 } 62 63 72 73 public int getProperties() { 74 return GROUNDED | LAST_POSITION_FINDER | LOOKAHEAD; 75 } 76 77 83 84 public Value materialize() { 85 return new SequenceExtent(list); 86 } 87 88 } 89 90 108 | Popular Tags |