/Users/lyon/j4p/src/javassist/CtMember.java
|
1 /*
2 * Javassist, a Java-bytecode translator toolkit.
3 * Copyright (C) 1999-2003 Shigeru Chiba. All Rights Reserved.
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. Alternatively, the contents of this file may be used under
8 * the terms of the GNU Lesser General Public License Version 2.1 or later.
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 */
15
16 package javassist;
17
18 /**
19 * An instance of <code>CtMember</code> represents a field, a constructor,
20 * or a method.
21 */
22 public abstract class CtMember {
23 protected CtClass declaringClass;
24
25 protected CtMember(CtClass clazz) {
26 declaringClass = clazz;
27 }
28
29 /**
30 * Returns the class that declares this member.
31 */
32 public CtClass getDeclaringClass() {
33 return declaringClass;
34 }
35
36 /**
37 * Obtains the modifiers of the member.
38 *
39 * @return modifiers encoded with
40 * <code>javassist.Modifier</code>.
41 * @see Modifier
42 */
43 public abstract int getModifiers();
44
45 /**
46 * Sets the encoded modifiers of the member.
47 *
48 * @see Modifier
49 */
50 public abstract void setModifiers(int mod);
51
52 /**
53 * Obtains the name of the member.
54 */
55 public abstract String getName();
56
57 /**
58 * Obtains an attribute with the given name.
59 * If that attribute is not found in the class file, this
60 * method returns null.
61 *
62 * @param name attribute name
63 */
64 public abstract byte[] getAttribute(String name);
65
66 /**
67 * Adds an attribute. The attribute is saved in the class file.
68 *
69 * @param name attribute name
70 * @param data attribute value
71 */
72 public abstract void setAttribute(String name, byte[] data);
73 }
74