KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > structures > elementvalues > EnumElementValue


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.elementvalues;
8
9 import org.gjt.jclasslib.structures.InvalidByteCodeException;
10
11 import java.io.*;
12
13 /**
14  * Describes an <tt>EnumElementValue</tt> attribute structure.
15  *
16  * @author <a HREF="mailto:vitor.carreira@gmail.com">Vitor Carreira</a>
17  * @version $Revision: 1.1 $ $Date: 2004/12/28 13:04:32 $
18  */

19 public class EnumElementValue extends ElementValue {
20
21     public final static String JavaDoc ENTRY_NAME = "EnumElement";
22
23     private static final int LENGTH = 4;
24     private int typeNameIndex;
25     private int constNameIndex;
26
27     protected EnumElementValue() {
28         super(ENUM_TAG);
29     }
30
31     /**
32      * Get the <tt>type_name_index</tt> of this element value entry.
33      *
34      * @return the <tt>type_name_index</tt>
35      */

36     public int getTypeNameIndex() {
37         return this.typeNameIndex;
38     }
39
40     /**
41      * Set the <tt>type_name_index</tt> of this element value entry.
42      *
43      * @param typeNameIndex the <tt>type_name_index</tt>
44      */

45     public void setTypeNameIndex(int typeNameIndex) {
46         this.typeNameIndex = typeNameIndex;
47     }
48
49     /**
50      * Get the <tt>const_name_index</tt> of this element value entry.
51      *
52      * @return the <tt>const_name_index</tt>
53      */

54     public int getConstNameIndex() {
55         return this.constNameIndex;
56     }
57
58     /**
59      * Set the <tt>const_name_index</tt> of this element value entry.
60      *
61      * @param constNameIndex the <tt>const_name_index</tt>
62      */

63     public void setConstNameIndex(int constNameIndex) {
64         this.constNameIndex = constNameIndex;
65     }
66
67
68     protected int getSpecificLength() {
69         return LENGTH;
70     }
71
72     public void read(DataInput in) throws InvalidByteCodeException, IOException {
73         super.read(in);
74         typeNameIndex = in.readUnsignedShort();
75         constNameIndex = in.readUnsignedShort();
76
77         if (debug) debug("read ");
78     }
79
80     public void write(DataOutput out) throws InvalidByteCodeException, IOException {
81         super.write(out);
82         out.writeShort(typeNameIndex);
83         out.writeShort(constNameIndex);
84
85         if (debug) debug("wrote ");
86     }
87
88     protected void debug(String JavaDoc message) {
89         super.debug(message +
90                 "EnumElementValue with type_name_index " +
91                 typeNameIndex + ", const_name_index " + constNameIndex);
92
93     }
94
95     public String JavaDoc getEntryName() {
96         return ENTRY_NAME;
97     }
98
99 }
100
Popular Tags