ej-technologies

org.gjt.jclasslib.structures.constants
Class ConstantReference

java.lang.Object
  extended byorg.gjt.jclasslib.structures.AbstractStructure
      extended byorg.gjt.jclasslib.structures.CPInfo
          extended byorg.gjt.jclasslib.structures.constants.ConstantReference
Direct Known Subclasses:
ConstantFieldrefInfo, ConstantInterfaceMethodrefInfo, ConstantMethodrefInfo

public abstract class ConstantReference
extends CPInfo

Base class for constant pool data structures which reference class members.

Version:
$Revision: 1.5 $ $Date: 2003/08/18 07:50:25 $
Author:
Ingo Kegel

Field Summary
protected  int classIndex
          class_index field.
protected  int nameAndTypeIndex
          name_and_type_index field.
static int SIZE
          Length of the constant pool data structure in bytes.
 
Fields inherited from class org.gjt.jclasslib.structures.CPInfo
CONSTANT_CLASS, CONSTANT_CLASS_VERBOSE, CONSTANT_DOUBLE, CONSTANT_DOUBLE_VERBOSE, CONSTANT_FIELDREF, CONSTANT_FIELDREF_VERBOSE, CONSTANT_FLOAT, CONSTANT_FLOAT_VERBOSE, CONSTANT_INTEGER, CONSTANT_INTEGER_VERBOSE, CONSTANT_INTERFACE_METHODREF, CONSTANT_INTERFACE_METHODREF_VERBOSE, CONSTANT_LONG, CONSTANT_LONG_VERBOSE, CONSTANT_METHODREF, CONSTANT_METHODREF_VERBOSE, CONSTANT_NAME_AND_TYPE, CONSTANT_NAME_AND_TYPE_VERBOSE, CONSTANT_STRING, CONSTANT_STRING_VERBOSE, CONSTANT_UTF8, CONSTANT_UTF8_VERBOSE
 
Fields inherited from class org.gjt.jclasslib.structures.AbstractStructure
classFile, debug, SYSTEM_PROPERTY_DEBUG
 
Constructor Summary
ConstantReference()
           
 
Method Summary
 boolean equals(Object object)
           
 int getClassIndex()
          Get the index of the constant pool entry containing the CONSTANT_Class_info of this entry.
 ConstantClassInfo getClassInfo()
          Get the class info for this reference.
 int getNameAndTypeIndex()
          Get the index of the constant pool entry containing the CONSTANT_NameAndType_info of this entry.
 ConstantNameAndTypeInfo getNameAndTypeInfo()
          Get the name and type info for this reference.
 String getVerbose()
          Get the verbose description of the content of the constant pool entry.
 int hashCode()
           
 void read(DataInput in)
          Read this structure from the given DataInput.
 void setClassIndex(int classIndex)
          Set the index of the constant pool entry containing the CONSTANT_Class_info of this entry.
 void setNameAndTypeIndex(int nameAndTypeIndex)
          Set the index of the constant pool entry containing the CONSTANT_NameAndType_info of this entry.
 void write(DataOutput out)
          Write this structure to the given DataOutput.
 
Methods inherited from class org.gjt.jclasslib.structures.CPInfo
create, getTag, getTagVerbose, printAccessFlagsVerbose, skip
 
Methods inherited from class org.gjt.jclasslib.structures.AbstractStructure
debug, getClassFile, getDebug, getLength, printAccessFlags, printAccessFlagsVerbose, printBytes, setClassFile, setDebug
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZE

public static final int SIZE
Length of the constant pool data structure in bytes.

See Also:
Constant Field Values

classIndex

protected int classIndex
class_index field.


nameAndTypeIndex

protected int nameAndTypeIndex
name_and_type_index field.

Constructor Detail

ConstantReference

public ConstantReference()
Method Detail

getVerbose

public String getVerbose()
                  throws InvalidByteCodeException
Description copied from class: CPInfo
Get the verbose description of the content of the constant pool entry.

Overrides:
getVerbose in class CPInfo
Returns:
the verbose description
Throws:
InvalidByteCodeException - if the byte code is invalid

getClassIndex

public int getClassIndex()
Get the index of the constant pool entry containing the CONSTANT_Class_info of this entry.

Returns:
the index

setClassIndex

public void setClassIndex(int classIndex)
Set the index of the constant pool entry containing the CONSTANT_Class_info of this entry.

Parameters:
classIndex - the index

getNameAndTypeIndex

public int getNameAndTypeIndex()
Get the index of the constant pool entry containing the CONSTANT_NameAndType_info of this entry.

Returns:
the index

setNameAndTypeIndex

public void setNameAndTypeIndex(int nameAndTypeIndex)
Set the index of the constant pool entry containing the CONSTANT_NameAndType_info of this entry.

Parameters:
nameAndTypeIndex - the index

getClassInfo

public ConstantClassInfo getClassInfo()
                               throws InvalidByteCodeException
Get the class info for this reference.

Returns:
the class info.
Throws:
InvalidByteCodeException

getNameAndTypeInfo

public ConstantNameAndTypeInfo getNameAndTypeInfo()
                                           throws InvalidByteCodeException
Get the name and type info for this reference.

Returns:
the name and type info.
Throws:
InvalidByteCodeException

read

public void read(DataInput in)
          throws InvalidByteCodeException,
                 IOException
Description copied from class: AbstractStructure
Read this structure from the given DataInput.

Excpects DataInput to be in JVM class file format and just before a structure of this kind. No look ahead parsing since the class file format is deterministic.

Overrides:
read in class AbstractStructure
Parameters:
in - the DataInput from which to read
Throws:
InvalidByteCodeException - if the byte code is invalid
IOException - if an exception occurs with the DataInput

write

public void write(DataOutput out)
           throws InvalidByteCodeException,
                  IOException
Description copied from class: AbstractStructure
Write this structure to the given DataOutput.

The written bytes are in JVM class file format.

Overrides:
write in class AbstractStructure
Parameters:
out - the DataOutput to which to write
Throws:
IOException - if an exception occurs with the DataOutput
InvalidByteCodeException - if the structure is internally inconsistent

equals

public boolean equals(Object object)
Overrides:
equals in class CPInfo

hashCode

public int hashCode()
Overrides:
hashCode in class CPInfo

ej-technologies