alt.jiapi.file
Class ConstantPool

java.lang.Object
  extended by alt.jiapi.file.ConstantPool

public class ConstantPool
extends java.lang.Object

Class ConstantPool.

Author:
Mika Riekkinen

Nested Class Summary
 class ConstantPool.ClassInfo
          Represents a CONSTANT_Class_info in constant pool
 class ConstantPool.DoubleInfo
           
 class ConstantPool.Entry
          Base class for entries in ConstantPool.
 class ConstantPool.FieldRefInfo
          Represents a CONSTANT_FieldRef in constant pool
 class ConstantPool.FloatInfo
           
 class ConstantPool.IntegerInfo
           
 class ConstantPool.InterfaceMethodRefInfo
          Represents a CONSTANT_InterfaceMethodRef in constant pool
 class ConstantPool.LongInfo
           
 class ConstantPool.MethodRefInfo
          Represents a CONSTANT_MethodRef in constant pool
 class ConstantPool.NameAndTypeInfo
          Represents a CONSTANT_NameAndType in constant pool
 class ConstantPool.NullEntry
           
 class ConstantPool.StringInfo
           
 class ConstantPool.Utf8Info
           
 
Field Summary
static byte CONSTANT_Class
          Constant, that represents a class_ref tag in constant pool
static byte CONSTANT_Double
          Constant, that represents a double tag in constant pool
static byte CONSTANT_Fieldref
          Constant, that represents a field_ref tag in constant pool
static byte CONSTANT_Float
          Constant, that represents a float tag in constant pool
static byte CONSTANT_Integer
          Constant, that represents a integer tag in constant pool
static byte CONSTANT_InterfaceMethodref
          Constant, that represents a interfacemethod_ref tag in constant pool
static byte CONSTANT_Long
          Constant, that represents a long tag in constant pool
static byte CONSTANT_Methodref
          Constant, that represents a method_ref tag in constant pool
static byte CONSTANT_NameAndType
          Constant, that represents a nameAndType tag in constant pool
static byte CONSTANT_String
          Constant, that represents a string tag in constant pool
static byte CONSTANT_Utf8
          Constant, that represents a Utf8 tag in constant pool
 
Constructor Summary
ConstantPool()
          Creates an empty constant pool.
 
Method Summary
 short add(ConstantPool.Entry entry)
          Adds an entry to this constant pool.
 ConstantPool.ClassInfo addClassInfo(java.lang.String className)
          Adds a new ClassInfo.
 ConstantPool.DoubleInfo addDoubleInfo(int highBytes, int lowBytes)
          Adds a new DoubleInfo.
 ConstantPool.FieldRefInfo addFieldRefInfo(ConstantPool.ClassInfo ci, java.lang.String name, java.lang.String desc)
          Adds a new FieldRefInfo.
 ConstantPool.FloatInfo addFloatInfo(int bytes)
          Adds a new FloatInfo.
 ConstantPool.IntegerInfo addIntegerInfo(int bytes)
          Adds a new IntegerInfo.
 ConstantPool.InterfaceMethodRefInfo addInterfaceMethodRefInfo(ConstantPool.ClassInfo ci, java.lang.String name, java.lang.String desc)
          Adds a new InterfaceMethodRefInfo.
 ConstantPool.LongInfo addLongInfo(int highBytes, int lowBytes)
          Adds a new LongInfo.
 ConstantPool.MethodRefInfo addMethodRefInfo(ConstantPool.ClassInfo ci, java.lang.String name, java.lang.String desc)
          Adds a new MethodRefInfo.
 ConstantPool.NameAndTypeInfo addNameAndTypeInfo(java.lang.String name, java.lang.String descriptor)
          Adds a new NameAndTypeInfo.
 ConstantPool.StringInfo addStringInfo(java.lang.String s)
          Adds a new StringInfo.
 ConstantPool.Utf8Info addUtf8Info(java.lang.String s)
          Adds a new Utf8Info.
 ConstantPool.Entry get(int index)
          Gets an entry from constant pool.
 java.lang.String getClassName(short index)
          Index must point to a Class_info structure in Constant pool
 java.lang.String getStringValue(short index)
          Gets a String at given constant pool index.
 java.lang.String getUtf8(short index)
          Gets a String at given constant pool index.
 int size()
          Get the size of this ConstantPool.
 byte[] toBytes()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONSTANT_Class

public static final byte CONSTANT_Class
Constant, that represents a class_ref tag in constant pool

See Also:
Constant Field Values

CONSTANT_Double

public static final byte CONSTANT_Double
Constant, that represents a double tag in constant pool

See Also:
Constant Field Values

CONSTANT_Fieldref

public static final byte CONSTANT_Fieldref
Constant, that represents a field_ref tag in constant pool

See Also:
Constant Field Values

CONSTANT_Float

public static final byte CONSTANT_Float
Constant, that represents a float tag in constant pool

See Also:
Constant Field Values

CONSTANT_Integer

public static final byte CONSTANT_Integer
Constant, that represents a integer tag in constant pool

See Also:
Constant Field Values

CONSTANT_InterfaceMethodref

public static final byte CONSTANT_InterfaceMethodref
Constant, that represents a interfacemethod_ref tag in constant pool

See Also:
Constant Field Values

CONSTANT_Long

public static final byte CONSTANT_Long
Constant, that represents a long tag in constant pool

See Also:
Constant Field Values

CONSTANT_Methodref

public static final byte CONSTANT_Methodref
Constant, that represents a method_ref tag in constant pool

See Also:
Constant Field Values

CONSTANT_NameAndType

public static final byte CONSTANT_NameAndType
Constant, that represents a nameAndType tag in constant pool

See Also:
Constant Field Values

CONSTANT_String

public static final byte CONSTANT_String
Constant, that represents a string tag in constant pool

See Also:
Constant Field Values

CONSTANT_Utf8

public static final byte CONSTANT_Utf8
Constant, that represents a Utf8 tag in constant pool

See Also:
Constant Field Values
Constructor Detail

ConstantPool

public ConstantPool()
Creates an empty constant pool.

Method Detail

add

public short add(ConstantPool.Entry entry)
Adds an entry to this constant pool. If entry has sub-entries, those are added also.


addClassInfo

public ConstantPool.ClassInfo addClassInfo(java.lang.String className)
Adds a new ClassInfo.

Parameters:
className - a fully qualified class name
Returns:
ClassInfo

addDoubleInfo

public ConstantPool.DoubleInfo addDoubleInfo(int highBytes,
                                             int lowBytes)
Adds a new DoubleInfo.

Parameters:
highBytes - double constant
lowBytes - double constant
Returns:
DoubleInfo

addFieldRefInfo

public ConstantPool.FieldRefInfo addFieldRefInfo(ConstantPool.ClassInfo ci,
                                                 java.lang.String name,
                                                 java.lang.String desc)
Adds a new FieldRefInfo.

Parameters:
ci - ClassInfo, that is supposed to contain created field reference
name - Name of the field
desc - descriptor of the field
Returns:
FieldRefInfo

addFloatInfo

public ConstantPool.FloatInfo addFloatInfo(int bytes)
Adds a new FloatInfo.

Parameters:
bytes - float constant
Returns:
FloatInfo

addIntegerInfo

public ConstantPool.IntegerInfo addIntegerInfo(int bytes)
Adds a new IntegerInfo.

Parameters:
bytes - integer constant
Returns:
IntegerInfo

addInterfaceMethodRefInfo

public ConstantPool.InterfaceMethodRefInfo addInterfaceMethodRefInfo(ConstantPool.ClassInfo ci,
                                                                     java.lang.String name,
                                                                     java.lang.String desc)
Adds a new InterfaceMethodRefInfo.

Parameters:
ci - ClassInfo, that is supposed to contain created interface method reference
name - Name of the method
desc - descriptor of the method
Returns:
InterfaceMethodRefInfo

addLongInfo

public ConstantPool.LongInfo addLongInfo(int highBytes,
                                         int lowBytes)
Adds a new LongInfo.

Parameters:
highBytes - long constant
lowBytes - long constant
Returns:
LongInfo

addMethodRefInfo

public ConstantPool.MethodRefInfo addMethodRefInfo(ConstantPool.ClassInfo ci,
                                                   java.lang.String name,
                                                   java.lang.String desc)
Adds a new MethodRefInfo.

Parameters:
ci - ClassInfo, that is supposed to contain created method reference
name - Name of the method
desc - descriptor of the method
Returns:
MethodRefInfo

addNameAndTypeInfo

public ConstantPool.NameAndTypeInfo addNameAndTypeInfo(java.lang.String name,
                                                       java.lang.String descriptor)
Adds a new NameAndTypeInfo.

Parameters:
name - Name to add
descriptor - descriptor to add
Returns:
NameAndTypeInfo

addStringInfo

public ConstantPool.StringInfo addStringInfo(java.lang.String s)
Adds a new StringInfo.

Parameters:
s - String constant to add
Returns:
StringInfo

addUtf8Info

public ConstantPool.Utf8Info addUtf8Info(java.lang.String s)
Adds a new Utf8Info.

Parameters:
s - String to add
Returns:
Utf8Info

get

public ConstantPool.Entry get(int index)
Gets an entry from constant pool. Indexing starts from 1.

Parameters:
index - index into constant pool
Returns:
An instance of Entry

getClassName

public java.lang.String getClassName(short index)
Index must point to a Class_info structure in Constant pool

Parameters:
index - index to ClassInfo in constant pool.
Returns:
an internal representation of classname, like java/lang/Object
Throws:
java.lang.IllegalArgumentException - is throw, if entry at given index does not point into ClassInfo, or ClassInfo.getNameIndex() does not point to Utf8Info

getStringValue

public java.lang.String getStringValue(short index)
Gets a String at given constant pool index. index must point to a StringInfo or Utf8Info.

Parameters:
index - index into constant pool
Returns:
a String
Throws:
java.lang.IllegalArgumentException - is throw, if entry at given index does not point into StringInfo or utf8Info

getUtf8

public java.lang.String getUtf8(short index)
Gets a String at given constant pool index. index must point to a Utf8Info.

Parameters:
index - index into constant pool
Returns:
An instance of Entry
Throws:
java.lang.IllegalArgumentException - is throw, if entry at given index does not point into Utf8Info

size

public int size()
Get the size of this ConstantPool.

Returns:
number of entries in constant-pool

toBytes

public byte[] toBytes()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2001. Documenation generated August 26 2011.