KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > ba > type > ExceptionSetFactory


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

19
20 package edu.umd.cs.findbugs.ba.type;
21
22 import java.io.Serializable JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.HashMap JavaDoc;
25
26 import org.apache.bcel.generic.ObjectType;
27
28 public class ExceptionSetFactory implements Serializable JavaDoc {
29     /**
30      *
31      */

32     private static final long serialVersionUID = 1L;
33     private HashMap JavaDoc<ObjectType, Integer JavaDoc> typeIndexMap;
34     private ArrayList JavaDoc<ObjectType> typeList;
35
36     public ExceptionSetFactory() {
37         this.typeIndexMap = new HashMap JavaDoc<ObjectType, Integer JavaDoc>();
38         this.typeList = new ArrayList JavaDoc<ObjectType>();
39     }
40
41     public ExceptionSet createExceptionSet() {
42         return new ExceptionSet(this);
43     }
44
45     int getIndexOfType(ObjectType type) {
46         Integer JavaDoc index = typeIndexMap.get(type);
47         if (index == null) {
48             index = (Integer JavaDoc)(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 // vim:ts=3
65
Popular Tags