1 11 package org.eclipse.ant.internal.ui.editor.text; 12 13 import java.util.Iterator ; 14 import org.eclipse.jface.text.source.IAnnotationModel; 15 16 17 20 public class XMLAnnotationIterator implements Iterator { 21 22 private Iterator fIterator; 23 private IXMLAnnotation fNext; 24 private boolean fSkipIrrelevants; 25 26 public XMLAnnotationIterator(IAnnotationModel model, boolean skipIrrelevants) { 27 fIterator= model.getAnnotationIterator(); 28 fSkipIrrelevants= skipIrrelevants; 29 skip(); 30 } 31 32 private void skip() { 33 while (fIterator.hasNext()) { 34 Object next= fIterator.next(); 35 if (next instanceof IXMLAnnotation) { 36 IXMLAnnotation a= (IXMLAnnotation) next; 37 if (fSkipIrrelevants) { 38 if (a.isRelevant()) { 39 fNext= a; 40 return; 41 } 42 } else { 43 fNext= a; 44 return; 45 } 46 } 47 } 48 fNext= null; 49 } 50 51 54 public boolean hasNext() { 55 return fNext != null; 56 } 57 58 61 public Object next() { 62 try { 63 return fNext; 64 } finally { 65 skip(); 66 } 67 } 68 69 72 public void remove() { 73 throw new UnsupportedOperationException (); 74 } 75 } 76 | Popular Tags |