Package com.tonic.parser.constpool
Class Item<T>
- java.lang.Object
-
- com.tonic.parser.constpool.Item<T>
-
- Type Parameters:
T- The type of the value held by the constant pool item.
- Direct Known Subclasses:
ClassRefItem,ConstantDynamicItem,DoubleItem,FieldRefItem,FloatItem,IntegerItem,InterfaceRefItem,InvokeDynamicItem,LongItem,MethodHandleItem,MethodRefItem,MethodTypeItem,ModuleItem,NameAndTypeRefItem,PackageItem,StringRefItem,Utf8Item
public abstract class Item<T> extends Object
Abstract representation of a constant pool item.
-
-
Field Summary
Fields Modifier and Type Field Description static byteITEM_CLASS_REFstatic byteITEM_DOUBLEstatic byteITEM_DYNAMICstatic byteITEM_FIELD_REFstatic byteITEM_FLOATstatic byteITEM_INTEGERstatic byteITEM_INTERFACE_REFstatic byteITEM_INVOKEDYNAMICstatic byteITEM_LONGstatic byteITEM_METHOD_HANDLEstatic byteITEM_METHOD_REFstatic byteITEM_METHOD_TYPEstatic byteITEM_MODULEstatic byteITEM_NAME_TYPE_REFstatic byteITEM_PACKAGEstatic byteITEM_STRING_REFstatic byteITEM_UTF_8
-
Constructor Summary
Constructors Constructor Description Item()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaccept(AbstractClassVisitor visitor)Accepts a visitor for the visitor pattern.intgetIndex(ConstPool constPool)Gets the index of this item in the constant pool.abstract bytegetType()Returns the type of the constant pool item.abstract TgetValue()Returns the value held by the constant pool item.abstract voidread(ClassFile classFile)Reads the constant pool item from the class file.voidsetClassFile(ClassFile classFile)Binds this item to the class file that owns its pool.abstract voidwrite(DataOutputStream dos)Writes the item to the output stream (excluding the tag byte, which is written by the caller).
-
-
-
Field Detail
-
ITEM_UTF_8
public static final byte ITEM_UTF_8
- See Also:
- Constant Field Values
-
ITEM_INTEGER
public static final byte ITEM_INTEGER
- See Also:
- Constant Field Values
-
ITEM_FLOAT
public static final byte ITEM_FLOAT
- See Also:
- Constant Field Values
-
ITEM_LONG
public static final byte ITEM_LONG
- See Also:
- Constant Field Values
-
ITEM_DOUBLE
public static final byte ITEM_DOUBLE
- See Also:
- Constant Field Values
-
ITEM_CLASS_REF
public static final byte ITEM_CLASS_REF
- See Also:
- Constant Field Values
-
ITEM_STRING_REF
public static final byte ITEM_STRING_REF
- See Also:
- Constant Field Values
-
ITEM_FIELD_REF
public static final byte ITEM_FIELD_REF
- See Also:
- Constant Field Values
-
ITEM_METHOD_REF
public static final byte ITEM_METHOD_REF
- See Also:
- Constant Field Values
-
ITEM_INTERFACE_REF
public static final byte ITEM_INTERFACE_REF
- See Also:
- Constant Field Values
-
ITEM_NAME_TYPE_REF
public static final byte ITEM_NAME_TYPE_REF
- See Also:
- Constant Field Values
-
ITEM_METHOD_HANDLE
public static final byte ITEM_METHOD_HANDLE
- See Also:
- Constant Field Values
-
ITEM_METHOD_TYPE
public static final byte ITEM_METHOD_TYPE
- See Also:
- Constant Field Values
-
ITEM_DYNAMIC
public static final byte ITEM_DYNAMIC
- See Also:
- Constant Field Values
-
ITEM_INVOKEDYNAMIC
public static final byte ITEM_INVOKEDYNAMIC
- See Also:
- Constant Field Values
-
ITEM_PACKAGE
public static final byte ITEM_PACKAGE
- See Also:
- Constant Field Values
-
ITEM_MODULE
public static final byte ITEM_MODULE
- See Also:
- Constant Field Values
-
-
Method Detail
-
setClassFile
public void setClassFile(ClassFile classFile)
Binds this item to the class file that owns its pool.- Parameters:
classFile- the owning class file
-
read
public abstract void read(ClassFile classFile)
Reads the constant pool item from the class file.- Parameters:
classFile- The ClassFile utility to read data.
-
write
public abstract void write(DataOutputStream dos) throws IOException
Writes the item to the output stream (excluding the tag byte, which is written by the caller).- Parameters:
dos- The output stream to write to.- Throws:
IOException- If an I/O error occurs.
-
getType
public abstract byte getType()
Returns the type of the constant pool item.- Returns:
- The constant pool tag.
-
getValue
public abstract T getValue()
Returns the value held by the constant pool item.- Returns:
- The value of type T.
-
accept
public void accept(AbstractClassVisitor visitor)
Accepts a visitor for the visitor pattern.- Parameters:
visitor- The visitor to accept.
-
getIndex
public int getIndex(ConstPool constPool)
Gets the index of this item in the constant pool.- Parameters:
constPool- The constant pool to search.- Returns:
- The index of this item.
-
-