01: /*
02: * Bytecode Analysis Framework
03: * Copyright (C) 2005, 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: package edu.umd.cs.findbugs.ba;
20:
21: import org.apache.bcel.Constants;
22:
23: import edu.umd.cs.findbugs.classfile.DescriptorFactory;
24: import edu.umd.cs.findbugs.classfile.MethodDescriptor;
25: import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;
26: import edu.umd.cs.findbugs.util.ClassName;
27:
28: public abstract class AbstractMethod extends AbstractClassMember
29: implements XMethod {
30: protected AbstractMethod(@DottedClassName
31: String className, String methodName, String methodSig,
32: int accessFlags) {
33: super (className, methodName, methodSig, accessFlags);
34: }
35:
36: public int getNumParams() {
37: // FIXME: cache this?
38: return new SignatureParser(getSignature()).getNumParameters();
39: }
40:
41: public boolean isNative() {
42: return (getAccessFlags() & Constants.ACC_NATIVE) != 0;
43: }
44:
45: public boolean isSynchronized() {
46: return (getAccessFlags() & Constants.ACC_SYNCHRONIZED) != 0;
47: }
48:
49: @Override
50: public String toString() {
51: return SignatureConverter.convertMethodSignature(this );
52: }
53:
54: /* (non-Javadoc)
55: * @see edu.umd.cs.findbugs.ba.XMethod#getMethodDescriptor()
56: */
57: public MethodDescriptor getMethodDescriptor() {
58: return DescriptorFactory.instance().getMethodDescriptor(
59: ClassName.toSlashedClassName(getClassName()),
60: getName(), getSignature(), isStatic());
61: }
62: }
|