View Javadoc

1   /*
2    * Created on Sep 23, 2003
3    *
4    * To change the template for this generated file go to
5    * Window>Preferences>Java>Code Generation>Code and Comments
6    */
7   package joeq.Compiler.Analysis.IPSSA.Utils;
8   
9   import java.util.Iterator;
10  import jwutil.util.Assert;
11  
12  /***
13   * @author livshits
14   * @version $Id: IteratorHelper.java 1931 2004-09-22 22:17:47Z joewhaley $
15   */
16  public class IteratorHelper {
17      public static class SingleIterator implements Iterator {
18          boolean _done;
19          Object  _obj;
20          
21          public SingleIterator(Object obj){
22              _done = false;
23              _obj  = obj; 
24          }
25          public boolean hasNext() {
26              return !_done;
27          }
28  
29          public Object next() {
30              Assert._assert(!_done);
31              return _obj;
32          }
33  
34          public void remove() {
35              Assert._assert(false);            
36          }    
37      }
38      
39      public static class EmptyIterator implements Iterator {
40          private EmptyIterator(){}
41          public boolean hasNext() {return false;}
42          public Object next() {
43              Assert._assert(false);
44              return null;
45          }
46          public void remove() {
47              Assert._assert(false);            
48          }
49          
50          public static class FACTORY {
51              static EmptyIterator _sample = null;
52              
53              public static EmptyIterator get(){
54                  if(_sample == null){
55                      _sample = new EmptyIterator();
56                  }
57                  
58                  return _sample;
59              }
60          }
61      }
62  }