1 19 20 package edu.umd.cs.findbugs.ba.type; 21 22 import java.io.Serializable ; 23 import java.util.ArrayList ; 24 import java.util.HashMap ; 25 26 import org.apache.bcel.generic.ObjectType; 27 28 public class ExceptionSetFactory implements Serializable { 29 32 private static final long serialVersionUID = 1L; 33 private HashMap <ObjectType, Integer > typeIndexMap; 34 private ArrayList <ObjectType> typeList; 35 36 public ExceptionSetFactory() { 37 this.typeIndexMap = new HashMap <ObjectType, Integer >(); 38 this.typeList = new ArrayList <ObjectType>(); 39 } 40 41 public ExceptionSet createExceptionSet() { 42 return new ExceptionSet(this); 43 } 44 45 int getIndexOfType(ObjectType type) { 46 Integer index = typeIndexMap.get(type); 47 if (index == null) { 48 index = (Integer )(getNumTypes()); 49 typeList.add(type); 50 typeIndexMap.put(type, index); 51 } 52 return index.intValue(); 53 } 54 55 ObjectType getType(int index) { 56 return typeList.get(index); 57 } 58 59 int getNumTypes() { 60 return typeList.size(); 61 } 62 } 63 64 | Popular Tags |