01: /*
02: * Javassist, a Java-bytecode translator toolkit.
03: * Copyright (C) 2004 Bill Burke. All Rights Reserved.
04: *
05: * The contents of this file are subject to the Mozilla Public License Version
06: * 1.1 (the "License"); you may not use this file except in compliance with
07: * the License. Alternatively, the contents of this file may be used under
08: * the terms of the GNU Lesser General Public License Version 2.1 or later.
09: *
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.bytecode.annotation;
17:
18: import javassist.ClassPool;
19: import javassist.bytecode.ConstPool;
20: import java.io.IOException;
21: import java.lang.reflect.Method;
22:
23: /**
24: * The value of a member declared in an annotation.
25: *
26: * @see Annotation#getMemberValue(String)
27: * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
28: * @author Shigeru Chiba
29: */
30: public abstract class MemberValue {
31: ConstPool cp;
32: char tag;
33:
34: MemberValue(char tag, ConstPool cp) {
35: this .cp = cp;
36: this .tag = tag;
37: }
38:
39: /**
40: * Returns the value. If the value type is a primitive type, the
41: * returned value is boxed.
42: */
43: abstract Object getValue(ClassLoader cl, ClassPool cp, Method m)
44: throws ClassNotFoundException;
45:
46: abstract Class getType(ClassLoader cl)
47: throws ClassNotFoundException;
48:
49: static Class loadClass(ClassLoader cl, String classname)
50: throws ClassNotFoundException {
51: return Class.forName(classname, true, cl);
52: }
53:
54: /**
55: * Accepts a visitor.
56: */
57: public abstract void accept(MemberValueVisitor visitor);
58:
59: /**
60: * Writes the value.
61: */
62: public abstract void write(AnnotationsWriter w) throws IOException;
63: }
|