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;
20 * Filters problems based on their types.
22 public class JavaAnnotationIterator implements Iterator {
24 private Iterator fIterator;
26 private Annotation fNext;
28 private boolean fSkipIrrelevants;
30 private boolean fReturnAllAnnotations;
34 * <code>JavaAnnotationIterator(model, skipIrrelevants, false)</code>.
36 public JavaAnnotationIterator(IAnnotationModel model,
37 boolean skipIrrelevants) {
38 this(model, skipIrrelevants, false);
42 * Returns a new JavaAnnotationIterator.
45 * the annotation model
46 * @param skipIrrelevants
47 * whether to skip irrelevant annotations
48 * @param returnAllAnnotations
49 * Whether to return non IJavaAnnotations as well
51 public JavaAnnotationIterator(IAnnotationModel model,
52 boolean skipIrrelevants, boolean returnAllAnnotations) {
53 fReturnAllAnnotations = returnAllAnnotations;
55 fIterator = model.getAnnotationIterator();
57 fIterator = Collections.EMPTY_LIST.iterator();
58 fSkipIrrelevants = skipIrrelevants;
63 while (fIterator.hasNext()) {
64 Annotation next = (Annotation) fIterator.next();
65 if (next instanceof IJavaAnnotation) {
66 if (fSkipIrrelevants) {
67 if (!next.isMarkedDeleted()) {
75 } else if (fReturnAllAnnotations) {
84 * @see Iterator#hasNext()
86 public boolean hasNext() {
91 * @see Iterator#next()
93 public Object next() {
102 * @see Iterator#remove()
104 public void remove() {
105 throw new UnsupportedOperationException();