1 17 18 19 20 package org.apache.fop.layoutmgr; 21 22 import java.util.List ; 23 import java.util.ListIterator ; 24 import java.util.NoSuchElementException ; 25 26 public class LMiter implements ListIterator { 27 28 29 protected List listLMs; 30 protected int curPos = 0; 31 32 private LayoutManager lp; 33 34 public LMiter(LayoutManager lp) { 35 this.lp = lp; 36 listLMs = lp.getChildLMs(); 37 } 38 39 public boolean hasNext() { 40 return (curPos < listLMs.size()) ? true : lp.createNextChildLMs(curPos); 41 } 42 43 public boolean hasPrevious() { 44 return (curPos > 0); 45 } 46 47 public Object previous() throws NoSuchElementException { 48 if (curPos > 0) { 49 return listLMs.get(--curPos); 50 } else { 51 throw new NoSuchElementException (); 52 } 53 } 54 55 public Object next() throws NoSuchElementException { 56 if (curPos < listLMs.size()) { 57 return listLMs.get(curPos++); 58 } else { 59 throw new NoSuchElementException (); 60 } 61 } 62 63 public void remove() throws NoSuchElementException { 64 if (curPos > 0) { 65 listLMs.remove(--curPos); 66 } else { 68 throw new NoSuchElementException (); 69 } 70 } 71 72 73 public void add(Object o) throws UnsupportedOperationException { 74 throw new UnsupportedOperationException ("LMiter doesn't support add"); 75 } 76 77 public void set(Object o) throws UnsupportedOperationException { 78 throw new UnsupportedOperationException ("LMiter doesn't support set"); 79 } 80 81 public int nextIndex() { 82 return curPos; 83 } 84 85 public int previousIndex() { 86 return curPos - 1; 87 } 88 89 } 90 | Popular Tags |