01: /*
02: * FindBugs - Find Bugs in Java programs
03: * Copyright (C) 2006-2007 University of Maryland
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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.classfile.engine.asm;
21:
22: import edu.umd.cs.findbugs.asm.FBClassReader;
23: import edu.umd.cs.findbugs.classfile.CheckedAnalysisException;
24: import edu.umd.cs.findbugs.classfile.ClassDescriptor;
25: import edu.umd.cs.findbugs.classfile.IAnalysisCache;
26: import edu.umd.cs.findbugs.classfile.RecomputableClassAnalysisEngine;
27: import edu.umd.cs.findbugs.classfile.analysis.ClassData;
28:
29: /**
30: * Analysis engine to produce an ASM ClassReader for a class.
31: *
32: * @author David Hovemeyer
33: */
34: public class ClassReaderAnalysisEngine extends
35: RecomputableClassAnalysisEngine<FBClassReader> {
36:
37: /* (non-Javadoc)
38: * @see edu.umd.cs.findbugs.classfile.IAnalysisEngine#analyze(edu.umd.cs.findbugs.classfile.IAnalysisCache, java.lang.Object)
39: */
40: public FBClassReader analyze(IAnalysisCache analysisCache,
41: ClassDescriptor descriptor) throws CheckedAnalysisException {
42:
43: ClassData classData = analysisCache.getClassAnalysis(
44: ClassData.class, descriptor);
45:
46: FBClassReader classReader = new FBClassReader(classData
47: .getData());
48:
49: return classReader;
50: }
51:
52: /* (non-Javadoc)
53: * @see edu.umd.cs.findbugs.classfile.IAnalysisEngine#registerWith(edu.umd.cs.findbugs.classfile.IAnalysisCache)
54: */
55: public void registerWith(IAnalysisCache analysisCache) {
56: analysisCache.registerClassAnalysisEngine(FBClassReader.class,
57: this);
58: }
59:
60: }
|