KickJava   Java API By Example, From Geeks To Geeks.

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


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>ConstElementValue</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 ConstElementValue extends ElementValue {
20
21     public final static String JavaDoc ENTRY_NAME = "ConstElement";
22
23     private static final int LENGTH = 2;
24     private int constValueIndex;
25
26     protected ConstElementValue(int tag) {
27         super(tag);
28     }
29
30     /**
31      * Get the <tt>const_value_index</tt> of this element value entry.
32      *
33      * @return the <tt>const_value_index</tt>
34      */

35     public int getConstValueIndex() {
36         return this.constValueIndex;
37     }
38
39     /**
40      * Set the <tt>const_value_index</tt> of this element value entry.
41      *
42      * @param constValueIndex the <tt>const_value_index</tt>
43      */

44     public void setConstValueIndex(int constValueIndex) {
45         this.constValueIndex = constValueIndex;
46     }
47
48     protected int getSpecificLength() {
49         return LENGTH;
50     }
51
52     public void read(DataInput in) throws InvalidByteCodeException, IOException {
53         super.read(in);
54
55         constValueIndex = in.readUnsignedShort();
56
57         if (debug) debug("read ");
58     }
59
60     public void write(DataOutput out) throws InvalidByteCodeException, IOException {
61         super.write(out);
62
63         out.writeShort(constValueIndex);
64
65         if (debug) debug("wrote ");
66     }
67
68     protected void debug(String JavaDoc message) {
69         super.debug(message +
70                 "ConstElementValue with const_value_index " +
71                 constValueIndex);
72     }
73
74     public String JavaDoc getEntryName() {
75         return ENTRY_NAME;
76     }
77 }
78
Popular Tags