KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > AnalysisCacheToRepositoryAdapter


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, 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;
21
22 import java.io.File JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.Map JavaDoc;
26
27 import org.apache.bcel.classfile.JavaClass;
28 import org.apache.bcel.util.ClassPath;
29 import org.apache.bcel.util.Repository;
30
31 import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
32 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
33 import edu.umd.cs.findbugs.classfile.Global;
34 import edu.umd.cs.findbugs.classfile.IClassPath;
35 import edu.umd.cs.findbugs.classfile.ICodeBase;
36 import edu.umd.cs.findbugs.util.ClassName;
37
38 /**
39  * An implementation of org.apache.bcel.util.Repository that
40  * uses the AnalysisCache as its backing store.
41  *
42  * @author David Hovemeyer
43  */

44 public class AnalysisCacheToRepositoryAdapter implements Repository {
45     /**
46      * Constructor.
47      */

48     public AnalysisCacheToRepositoryAdapter() {
49     }
50
51     /* (non-Javadoc)
52      * @see org.apache.bcel.util.Repository#clear()
53      */

54     public void clear() {
55         throw new UnsupportedOperationException JavaDoc();
56     }
57
58     /* (non-Javadoc)
59      * @see org.apache.bcel.util.Repository#findClass(java.lang.String)
60      */

61     public JavaClass findClass(String JavaDoc className) {
62         className = ClassName.toSlashedClassName(className);
63         ClassDescriptor classDescriptor = new ClassDescriptor(className);
64         return Global.getAnalysisCache().probeClassAnalysis(JavaClass.class, classDescriptor);
65     }
66
67     /* (non-Javadoc)
68      * @see org.apache.bcel.util.Repository#getClassPath()
69      */

70     public ClassPath getClassPath() {
71         throw new UnsupportedOperationException JavaDoc();
72     }
73
74     /* (non-Javadoc)
75      * @see org.apache.bcel.util.Repository#loadClass(java.lang.String)
76      */

77     public JavaClass loadClass(String JavaDoc className) throws ClassNotFoundException JavaDoc {
78         className = ClassName.toSlashedClassName(className);
79         ClassDescriptor classDescriptor = new ClassDescriptor(className);
80         try {
81             return Global.getAnalysisCache().getClassAnalysis(JavaClass.class, classDescriptor);
82         } catch (CheckedAnalysisException e) {
83             throw new ClassNotFoundException JavaDoc("Exception while looking for class " + className, e);
84         }
85     }
86
87     /* (non-Javadoc)
88      * @see org.apache.bcel.util.Repository#loadClass(java.lang.Class)
89      */

90     public JavaClass loadClass(Class JavaDoc cls) throws ClassNotFoundException JavaDoc {
91         return loadClass(cls.getName());
92     }
93
94     /* (non-Javadoc)
95      * @see org.apache.bcel.util.Repository#removeClass(org.apache.bcel.classfile.JavaClass)
96      */

97     public void removeClass(JavaClass arg0) {
98         throw new UnsupportedOperationException JavaDoc();
99     }
100
101     /* (non-Javadoc)
102      * @see org.apache.bcel.util.Repository#storeClass(org.apache.bcel.classfile.JavaClass)
103      */

104     public void storeClass(JavaClass cls) {
105         throw new UnsupportedOperationException JavaDoc();
106     }
107 }
108
Popular Tags