KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > classfile > AnnotationComponent


1 /*
2  * AnnotationComponent.java
3  *
4  * The contents of this file are subject to the terms of the Common Development
5  * and Distribution License (the License). You may not use this file except in
6  * compliance with the License.
7  *
8  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
9  * or http://www.netbeans.org/cddl.txt.
10  *
11  * When distributing Covered Code, include this CDDL Header Notice in each file
12  * and include the License file at http://www.netbeans.org/cddl.txt.
13  * If applicable, add the following below the CDDL Header, with the fields
14  * enclosed by brackets [] replaced by your own identifying information:
15  * "Portions Copyrighted [year] [name of copyright owner]"
16  *
17  * The Original Software is NetBeans. The Initial Developer of the Original
18  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
19  * Microsystems, Inc. All Rights Reserved.
20  *
21  * Contributor(s): Thomas Ball
22  *
23  * Version: $Revision: 1.7 $
24  */

25
26 package org.netbeans.modules.classfile;
27
28 import java.io.DataInputStream JavaDoc;
29 import java.io.IOException JavaDoc;
30
31 /**
32  * AnnotationComponent: a single annotation on a program element.
33  *
34  * @author Thomas Ball
35  */

36 public class AnnotationComponent {
37     String JavaDoc name;
38     ElementValue value;
39
40     static AnnotationComponent load(DataInputStream JavaDoc in, ConstantPool pool,
41                     boolean runtimeVisible)
42     throws IOException JavaDoc {
43     int iName = in.readUnsignedShort();
44     String JavaDoc name = ((CPName)pool.get(iName)).getName();
45     ElementValue value = ElementValue.load(in, pool, runtimeVisible);
46     return new AnnotationComponent(name, value);
47     }
48
49     AnnotationComponent(String JavaDoc name, ElementValue value) {
50     this.name = name;
51     this.value = value;
52     }
53
54     /**
55      * Returns the name of this component.
56      */

57     public final String JavaDoc getName() {
58     return name;
59     }
60
61     /**
62      * Returns the value for this component.
63      */

64     public final ElementValue getValue() {
65     return value;
66     }
67
68     public String JavaDoc toString() {
69     return "name=" + name + ", value=" + value;
70     }
71 }
72
Popular Tags