KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > jimple > toolkits > callgraph > Filter


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Ondrej Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package soot.jimple.toolkits.callgraph;
21 import soot.*;
22 import soot.util.queue.*;
23 import java.util.*;
24
25 /** Represents a subset of the edges in a call graph satisfying an EdgePredicate
26  * predicate.
27  * @author Ondrej Lhotak
28  */

29 public class Filter implements Iterator
30 {
31     private Iterator source;
32     private EdgePredicate pred;
33     private Edge next = null;
34     public Filter( EdgePredicate pred ) {
35         this.pred = pred;
36     }
37     public Iterator wrap( Iterator source ) {
38         this.source = source;
39         advance();
40         return this;
41     }
42     private void advance() {
43         while( source.hasNext() ) {
44             next = (Edge) source.next();
45             if( pred.want( next ) ) {
46                 return;
47             }
48         }
49         next = null;
50     }
51     public boolean hasNext() {
52         return next != null;
53     }
54     public Object JavaDoc next() {
55         Object JavaDoc ret = next;
56         advance();
57         return ret;
58     }
59     public void remove() {
60         throw new UnsupportedOperationException JavaDoc();
61     }
62 }
63
64
Popular Tags