KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javassist > bytecode > annotation > AnnotationMemberValue


1 /*
2  * Javassist, a Java-bytecode translator toolkit.
3  * Copyright (C) 2004 Bill Burke. 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 package javassist.bytecode.annotation;
16
17 import javassist.bytecode.ConstPool;
18 import java.io.IOException JavaDoc;
19
20 /**
21  * Nested annotation.
22  *
23  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
24  * @author Shigeru Chiba
25  */

26 public class AnnotationMemberValue extends MemberValue {
27     Annotation value;
28
29     /**
30      * Constructs an annotation member. The initial value is not specified.
31      */

32     public AnnotationMemberValue(ConstPool cp) {
33         this(null, cp);
34     }
35
36     /**
37      * Constructs an annotation member. The initial value is specified by
38      * the first parameter.
39      */

40     public AnnotationMemberValue(Annotation a, ConstPool cp) {
41         super('@', cp);
42         value = a;
43     }
44
45     /**
46      * Obtains the value.
47      */

48     public Annotation getValue() {
49         return value;
50     }
51
52     /**
53      * Sets the value of this member.
54      */

55     public void setValue(Annotation newValue) {
56         value = newValue;
57     }
58
59     /**
60      * Obtains the string representation of this object.
61      */

62     public String JavaDoc toString() {
63         return value.toString();
64     }
65
66     void write(AnnotationsWriter writer) throws IOException JavaDoc {
67         writer.annotationValue();
68         value.write(writer);
69     }
70
71     /**
72      * Accepts a visitor.
73      */

74     public void accept(MemberValueVisitor visitor) {
75         visitor.visitAnnotationMemberValue(this);
76     }
77 }
78
Popular Tags