1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpeclipse.phpeditor;
13 import java.util.Collections;
14 import java.util.Iterator;
16 import org.eclipse.jface.text.source.Annotation;
17 import org.eclipse.jface.text.source.IAnnotationModel;
21 * Filters problems based on their types.
23 public class JavaAnnotationIterator implements Iterator {
25 private Iterator fIterator;
26 private Annotation fNext;
27 private boolean fSkipIrrelevants;
28 private boolean fReturnAllAnnotations;
31 * Equivalent to <code>JavaAnnotationIterator(model, skipIrrelevants, false)</code>.
33 public JavaAnnotationIterator(IAnnotationModel model, boolean skipIrrelevants) {
34 this(model, skipIrrelevants, false);
38 * Returns a new JavaAnnotationIterator.
39 * @param model the annotation model
40 * @param skipIrrelevants whether to skip irrelevant annotations
41 * @param returnAllAnnotations Whether to return non IJavaAnnotations as well
43 public JavaAnnotationIterator(IAnnotationModel model, boolean skipIrrelevants, boolean returnAllAnnotations) {
44 fReturnAllAnnotations= returnAllAnnotations;
46 fIterator= model.getAnnotationIterator();
48 fIterator= Collections.EMPTY_LIST.iterator();
49 fSkipIrrelevants= skipIrrelevants;
54 while (fIterator.hasNext()) {
55 Annotation next= (Annotation) fIterator.next();
56 if (next instanceof IJavaAnnotation) {
57 if (fSkipIrrelevants) {
58 if (!next.isMarkedDeleted()) {
66 } else if (fReturnAllAnnotations) {
75 * @see Iterator#hasNext()
77 public boolean hasNext() {
82 * @see Iterator#next()
84 public Object next() {
93 * @see Iterator#remove()
95 public void remove() {
96 throw new UnsupportedOperationException();