KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > alt > jiapi > file > Field


1 package alt.jiapi.file;
2
3 import java.util.List JavaDoc;
4
5 /**
6  * This class represents a field, as described in Java Virtual
7  * Machine Specification, 2nd edition, chapter 4.5.
8  */

9 public class Field {
10     public static final short ACC_PUBLIC = 0x0001;
11     public static final short ACC_PRIVATE = 0x0002;
12     public static final short ACC_PROTECTED = 0x0004;
13     public static final short ACC_STATIC = 0x0008;
14     public static final short ACC_FINAL = 0x0010;
15     public static final short ACC_VOLATILE = 0x0040;
16     public static final short ACC_TRANSIENT = 0x0080;
17
18     private ConstantPool cp;
19
20     private short access_flags;
21     private short name_index;
22     private short descriptor_index;
23     private List JavaDoc attributes;
24
25     private transient Configuration config = new Configuration();
26
27     public Field(ConstantPool cp, short access_flags, String JavaDoc name,
28                  String JavaDoc descriptor, List JavaDoc attributes) {
29         this(cp, access_flags, cp.addUtf8Info(name).getEntryIndex(),
30              cp.addUtf8Info(descriptor).getEntryIndex(), attributes);
31     }
32
33     Field(ConstantPool cp, short access_flags, short name_index,
34           short descriptor_index, List JavaDoc attributes) {
35         this.cp = cp;
36         this.access_flags = access_flags;
37         this.name_index = name_index;
38         this.descriptor_index = descriptor_index;
39         this.attributes = attributes;
40     }
41
42     public short getAccessFlags() {
43         return access_flags;
44     }
45
46     public List JavaDoc getAttributes() {
47         if (config.getBoolean("alt.jiapi.file.strip-optional-attributes",true)){
48             return new java.util.LinkedList JavaDoc();
49         }
50
51         return attributes;
52     }
53
54     /**
55      * Get the name of this Field
56      */

57     public String JavaDoc getName() {
58         return cp.getUtf8(name_index);
59     }
60
61     /**
62      * Get the descriptor of this Field
63      */

64     public String JavaDoc getDescriptor() {
65         return cp.getUtf8(descriptor_index);
66     }
67
68     short getNameIndex() {
69         return name_index;
70     }
71     short getDescriptorIndex() {
72         return descriptor_index;
73     }
74 }
75
76
77
78
79
Popular Tags