2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
5 package org.apidesign.javap;
9 * @author Jaroslav Tulach <jtulach@netbeans.org>
11 public final class TrapDataIterator {
12 private final Hashtable exStart = new Hashtable();
13 private final Hashtable exStop = new Hashtable();
14 private TrapData[] current = new TrapData[10];
15 private int currentCount;
17 TrapDataIterator(Vector exceptionTable) {
18 for (int i=0 ; i < exceptionTable.size(); i++) {
19 final TrapData td = (TrapData)exceptionTable.elementAt(i);
20 exStart.put(td.start_pc, td);
21 exStop.put(td.end_pc, td);
25 public void advanceTo(int i) {
26 Short s = Short.valueOf((short)i);
27 TrapData e = (TrapData) exStart.get(s);
31 e = (TrapData) exStop.get(s);
37 public boolean useTry() {
38 return currentCount > 0;
41 public TrapData[] current() {
45 private void add(TrapData e) {
46 if (currentCount == current.length) {
47 TrapData[] data = new TrapData[currentCount * 2];
48 for (int i = 0; i < currentCount; i++) {
53 current[currentCount++] = e;
56 private void remove(TrapData e) {
58 while (from < currentCount) {
59 if (e == current[from++]) {
63 while (from < currentCount) {
64 current[from - 1] = current[from];