1
2
3
4 package joeq.Compiler.BytecodeAnalysis;
5
6 import java.util.List;
7 import java.util.ListIterator;
8 import java.util.NoSuchElementException;
9 import jwutil.collections.AppendListIterator;
10
11 /***
12 * Iterator for exception handlers in a bytecode CFG.
13 *
14 * @author John Whaley <jwhaley@alum.mit.edu>
15 * @version $Id: ExceptionHandlerIterator.java 2282 2005-05-28 11:14:27Z joewhaley $
16 */
17 public class ExceptionHandlerIterator implements ListIterator {
18
19 private final AppendListIterator iterator;
20
21 /*** Creates new ExceptionHandlerIterator */
22 public ExceptionHandlerIterator(List exs, ExceptionHandlerList parent) {
23 ListIterator l2 = parent==null?null:parent.iterator();
24 iterator = new AppendListIterator(exs.listIterator(), l2);
25 }
26 private ExceptionHandlerIterator() {
27 iterator = null;
28 }
29
30 public boolean hasPrevious() { return iterator.hasPrevious(); }
31 public boolean hasNext() { return iterator.hasNext(); }
32 public Object previous() { return iterator.previous(); }
33 public Object next() { return iterator.next(); }
34 public int previousIndex() { return iterator.previousIndex(); }
35 public int nextIndex() { return iterator.nextIndex(); }
36 public void remove() { iterator.remove(); }
37 public void set(Object o) { iterator.set(o); }
38 public void add(Object o) { iterator.add(o); }
39
40 public ExceptionHandler prevEH() { return (ExceptionHandler)previous(); }
41 public ExceptionHandler nextEH() { return (ExceptionHandler)next(); }
42
43 public static ExceptionHandlerIterator nullIterator() {
44 return new ExceptionHandlerIterator() {
45 public boolean hasPrevious() { return false; }
46 public boolean hasNext() { return false; }
47 public Object previous() { throw new NoSuchElementException(); }
48 public Object next() { throw new NoSuchElementException(); }
49 public int previousIndex() { return -1; }
50 public int nextIndex() { return 0; }
51 public void remove() { throw new IllegalStateException(); }
52 public void set(Object o) { throw new IllegalStateException(); }
53 public void add(Object o) { throw new UnsupportedOperationException(); }
54 public ExceptionHandler prevEH() { throw new NoSuchElementException(); }
55 public ExceptionHandler nextEH() { throw new NoSuchElementException(); }
56 };
57 }
58 }