KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

44     public void setClassInfoIndex(int classInfoIndex) {
45         this.classInfoIndex = classInfoIndex;
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         classInfoIndex = 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(classInfoIndex);
64
65         if (debug) debug("wrote ");
66     }
67
68     protected void debug(String JavaDoc message) {
69         super.debug(message +
70                 "ClassElementValue with class_info_index " +
71                 classInfoIndex);
72     }
73
74     public String JavaDoc getEntryName() {
75         return ENTRY_NAME;
76     }
77
78 }
79
Popular Tags