01: package sli.kim.classfile;
02:
03: import java.util.Vector;
04:
05: /**
06: * A class for storing information about methods.
07: *
08: * @see sli.kim.classfile.ClassInfo#addMethod()
09: */
10: public class MethodInfo extends CommonInfo {
11: private String signature;
12: private Vector exceptions = new Vector();
13: private CodeInfo codeInfo;
14: private boolean deprecated;
15:
16: public MethodInfo(short accessFlags, String name, String signature) {
17: setAccessFlags(accessFlags);
18: setName(name);
19: setSignature(signature);
20: }
21:
22: /**
23: * Set the signature of the method. For example "([I,S)Ljava/lang/String;"
24: *
25: * @see Signature
26: */
27: public void setSignature(String signature) {
28: this .signature = signature;
29: }
30:
31: /**
32: * Get the signature of the method.
33: *
34: * @see Signature
35: */
36: public String getSignature() {
37: return signature;
38: }
39:
40: /**
41: * Add a checked exception that the method throws.
42: */
43: public void addException(String exceptionName) {
44: exceptions.addElement(exceptionName);
45: }
46:
47: /**
48: * Get all checked exceptions that the method throws.
49: */
50: public String[] getExceptions() {
51: String[] list = new String[exceptions.size()];
52: exceptions.copyInto(list);
53: return list;
54: }
55:
56: /**
57: * Set information about this method's code. The CodeInfo need
58: * not be entirely filled in before this method is called.
59: */
60: public void setCodeInfo(CodeInfo codeInfo) {
61: this .codeInfo = codeInfo;
62: }
63:
64: /**
65: * Get the information about this method's code. If the method
66: * has no code, this will return null.
67: */
68: public CodeInfo getCodeInfo() {
69: return codeInfo;
70: }
71:
72: /**
73: * Set whether this method is deprecated. Methods are not
74: * deprecated until setDeprecated(true) is called.
75: */
76: public void setDeprecated(boolean d) {
77: deprecated = d;
78: }
79:
80: /**
81: * Get whether this method is deprecated. Methods are not
82: * deprecated until setDeprecated(true) is called.
83: */
84: public boolean isDeprecated() {
85: return deprecated;
86: }
87: }
|