00001 package de.fub.bytecode.classfile;
00002
00003 import java.io.*;
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 public abstract class ConstantCP extends Constant {
00015
00016
00017 protected int class_index, name_and_type_index;
00018
00019
00020
00021
00022
00023 protected ConstantCP(byte tag, int class_index,
00024 int name_and_type_index) {
00025 super(tag);
00026 this.class_index = class_index;
00027 this.name_and_type_index = name_and_type_index;
00028 }
00029
00030
00031
00032
00033
00034
00035
00036 ConstantCP(byte tag, DataInputStream file) throws IOException
00037 {
00038 this(tag, file.readUnsignedShort(), file.readUnsignedShort());
00039 }
00040
00041
00042
00043 public ConstantCP(ConstantCP c) {
00044 this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex());
00045 }
00046
00047
00048
00049
00050
00051
00052 public final void dump(DataOutputStream file) throws IOException
00053 {
00054 file.writeByte(tag);
00055 file.writeShort(class_index);
00056 file.writeShort(name_and_type_index);
00057 }
00058
00059
00060
00061 public final int getClassIndex() { return class_index; }
00062
00063
00064
00065 public final int getNameAndTypeIndex() { return name_and_type_index; }
00066
00067
00068
00069 public final void setClassIndex(int class_index) {
00070 this.class_index = class_index;
00071 }
00072
00073
00074
00075 public final void setNameAndTypeIndex(int name_and_type_index) {
00076 this.name_and_type_index = name_and_type_index;
00077 }
00078
00079
00080
00081 public final String toString() {
00082 return super.toString() + "(class_index = " + class_index +
00083 ", name_and_type_index = " + name_and_type_index + ")";
00084 }
00085 }