modification to debug on a remote server
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / JavaAnnotationIterator.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpeclipse.phpeditor;
12
13 import java.util.Iterator;
14
15 import org.eclipse.jface.text.source.IAnnotationModel;
16
17
18 /**
19  * Filters problems based on their types.
20  */
21 public class JavaAnnotationIterator implements Iterator {
22                         
23         private Iterator fIterator;
24         private IJavaAnnotation fNext;
25         private boolean fSkipIrrelevants;
26         
27         public JavaAnnotationIterator(IAnnotationModel model, boolean skipIrrelevants) {
28                 fIterator= model.getAnnotationIterator();
29                 fSkipIrrelevants= skipIrrelevants;
30                 skip();
31         }
32         
33         private void skip() {
34                 while (fIterator.hasNext()) {
35                         Object next= fIterator.next();
36                         if (next instanceof IJavaAnnotation) {
37                                 IJavaAnnotation a= (IJavaAnnotation) next;
38                                 if (fSkipIrrelevants) {
39                                         if (a.isRelevant()) {
40                                                 fNext= a;
41                                                 return;
42                                         }
43                                 } else {
44                                         fNext= a;
45                                         return;
46                                 }
47                         }
48                 }
49                 fNext= null;
50         }
51         
52         /*
53          * @see Iterator#hasNext()
54          */
55         public boolean hasNext() {
56                 return fNext != null;
57         }
58
59         /*
60          * @see Iterator#next()
61          */
62         public Object next() {
63                 try {
64                         return fNext;
65                 } finally {
66                         skip();
67                 }
68         }
69
70         /*
71          * @see Iterator#remove()
72          */
73         public void remove() {
74                 throw new UnsupportedOperationException();
75         }
76 }