KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > structures > attributes > AnnotationDefaultAttribute


1 /*
2     This library is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public
4     License as published by the Free Software Foundation; either
5     version 2 of the license, or (at your option) any later version.
6 */

7 package org.gjt.jclasslib.structures.attributes;
8
9 import org.gjt.jclasslib.structures.AttributeInfo;
10 import org.gjt.jclasslib.structures.InvalidByteCodeException;
11 import org.gjt.jclasslib.structures.elementvalues.ElementValue;
12
13 import java.io.*;
14
15 /**
16  * Describes an <tt>AnnotationDefault</tt> attribute structure.
17  *
18  * @author <a HREF="mailto:vitor.carreira@gmail.com">Vitor Carreira</a>
19  * @version $Revision: 1.1 $ $Date: 2004/12/28 13:04:31 $
20  */

21 public class AnnotationDefaultAttribute extends AttributeInfo {
22     /**
23      * Name of the attribute as in the corresponding constant pool entry.
24      */

25     public static final String JavaDoc ATTRIBUTE_NAME = "AnnotationDefault";
26
27     private ElementValue defaultValue;
28
29     /**
30      * Get the <tt>default_value</tt> of this attribute.
31      *
32      * @return the <tt>default_value</tt>
33      */

34     public ElementValue getDefaultValue() {
35         return this.defaultValue;
36     }
37
38     /**
39      * Set the <tt>default_value</tt> of this attribute.
40      *
41      * @param defaultValue the <tt>default_value</tt>
42      */

43     public void setDefaultValue(ElementValue defaultValue) {
44         this.defaultValue = defaultValue;
45     }
46
47     public void read(DataInput in)
48             throws InvalidByteCodeException, IOException {
49         super.read(in);
50
51         defaultValue = ElementValue.create(in, classFile);
52
53         if (debug) debug("read ");
54     }
55
56     public void write(DataOutput out)
57             throws InvalidByteCodeException, IOException {
58         super.write(out);
59
60         defaultValue.write(out);
61
62         if (debug) debug("wrote ");
63     }
64
65     public int getAttributeLength() {
66         return defaultValue.getLength();
67     }
68
69     protected void debug(String JavaDoc message) {
70         super.debug(message + "AnnotationDefaultAttribute");
71     }
72 }
73
Popular Tags