Package org.apache.bcel.classfile
Class ElementValue
- java.lang.Object
-
- org.apache.bcel.classfile.ElementValue
-
- Direct Known Subclasses:
AnnotationElementValue,ArrayElementValue,ClassElementValue,EnumElementValue,SimpleElementValue
public abstract class ElementValue extends java.lang.ObjectThe element_value structure is documented at https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.16.1element_value { u1 tag; union { u2 const_value_index; { u2 type_name_index; u2 const_name_index; } enum_const_value; u2 class_info_index; annotation annotation_value; { u2 num_values; element_value values[num_values]; } array_value; } value; }- Since:
- 6.0
-
-
Field Summary
Fields Modifier and Type Field Description static byteANNOTATIONElement value type: annotation.static byteARRAYElement value type: array.static byteCLASSElement value type: class.protected ConstantPoolcpoolDeprecated.(since 6.0) will be made private and final; do not access directly, use getter.(package private) static ElementValue[]EMPTY_ARRAYEmpty array constant.static byteENUM_CONSTANTElement value type: enum constant.static bytePRIMITIVE_BOOLEANElement value type: primitive boolean.static bytePRIMITIVE_BYTEElement value type: primitive byte.static bytePRIMITIVE_CHARElement value type: primitive char.static bytePRIMITIVE_DOUBLEElement value type: primitive double.static bytePRIMITIVE_FLOATElement value type: primitive float.static bytePRIMITIVE_INTElement value type: primitive int.static bytePRIMITIVE_LONGElement value type: primitive long.static bytePRIMITIVE_SHORTElement value type: primitive short.static byteSTRINGElement value type: string.protected inttypeDeprecated.(since 6.0) will be made private and final; do not access directly, use getter.
-
Constructor Summary
Constructors Modifier Constructor Description protectedElementValue(int type, ConstantPool cpool)Constructs an ElementValue.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voiddump(java.io.DataOutputStream dos)Dumps this element value to a DataOutputStream.(package private) ConstantPoolgetConstantPool()Gets the constant pool.intgetElementValueType()Gets the element value type.(package private) intgetType()Gets the type.static ElementValuereadElementValue(java.io.DataInput input, ConstantPool cpool)Reads anelement_valueas anElementValue.static ElementValuereadElementValue(java.io.DataInput input, ConstantPool cpool, int arrayNesting)Reads anelement_valueas anElementValue.abstract java.lang.StringstringifyValue()Returns a string representation of the element value.java.lang.StringtoShortString()Returns a short string representation of the element value.java.lang.StringtoString()Returns a string representation of the element value.
-
-
-
Field Detail
-
STRING
public static final byte STRING
Element value type: string.- See Also:
- Constant Field Values
-
ENUM_CONSTANT
public static final byte ENUM_CONSTANT
Element value type: enum constant.- See Also:
- Constant Field Values
-
CLASS
public static final byte CLASS
Element value type: class.- See Also:
- Constant Field Values
-
ANNOTATION
public static final byte ANNOTATION
Element value type: annotation.- See Also:
- Constant Field Values
-
ARRAY
public static final byte ARRAY
Element value type: array.- See Also:
- Constant Field Values
-
PRIMITIVE_INT
public static final byte PRIMITIVE_INT
Element value type: primitive int.- See Also:
- Constant Field Values
-
PRIMITIVE_BYTE
public static final byte PRIMITIVE_BYTE
Element value type: primitive byte.- See Also:
- Constant Field Values
-
PRIMITIVE_CHAR
public static final byte PRIMITIVE_CHAR
Element value type: primitive char.- See Also:
- Constant Field Values
-
PRIMITIVE_DOUBLE
public static final byte PRIMITIVE_DOUBLE
Element value type: primitive double.- See Also:
- Constant Field Values
-
PRIMITIVE_FLOAT
public static final byte PRIMITIVE_FLOAT
Element value type: primitive float.- See Also:
- Constant Field Values
-
PRIMITIVE_LONG
public static final byte PRIMITIVE_LONG
Element value type: primitive long.- See Also:
- Constant Field Values
-
PRIMITIVE_SHORT
public static final byte PRIMITIVE_SHORT
Element value type: primitive short.- See Also:
- Constant Field Values
-
PRIMITIVE_BOOLEAN
public static final byte PRIMITIVE_BOOLEAN
Element value type: primitive boolean.- See Also:
- Constant Field Values
-
EMPTY_ARRAY
static final ElementValue[] EMPTY_ARRAY
Empty array constant.
-
type
@Deprecated protected int type
Deprecated.(since 6.0) will be made private and final; do not access directly, use getter.
-
cpool
@Deprecated protected ConstantPool cpool
Deprecated.(since 6.0) will be made private and final; do not access directly, use getter.
-
-
Constructor Detail
-
ElementValue
protected ElementValue(int type, ConstantPool cpool)Constructs an ElementValue.- Parameters:
type- the element value type.cpool- the constant pool.
-
-
Method Detail
-
readElementValue
public static ElementValue readElementValue(java.io.DataInput input, ConstantPool cpool) throws java.io.IOException
Reads anelement_valueas anElementValue.- Parameters:
input- Raw data input.cpool- Constant pool.- Returns:
- a new ElementValue.
- Throws:
java.io.IOException- if an I/O error occurs.
-
readElementValue
public static ElementValue readElementValue(java.io.DataInput input, ConstantPool cpool, int arrayNesting) throws java.io.IOException
Reads anelement_valueas anElementValue.- Parameters:
input- Raw data input.cpool- Constant pool.arrayNesting- level of current array nesting.- Returns:
- a new ElementValue.
- Throws:
java.io.IOException- if an I/O error occurs.- Since:
- 6.7.0
-
dump
public abstract void dump(java.io.DataOutputStream dos) throws java.io.IOExceptionDumps this element value to a DataOutputStream.- Parameters:
dos- the output stream.- Throws:
java.io.IOException- if an I/O error occurs.
-
getConstantPool
final ConstantPool getConstantPool()
Gets the constant pool.- Returns:
- the constant pool.
- Since:
- 6.0
-
getElementValueType
public int getElementValueType()
Gets the element value type.- Returns:
- the element value type.
-
getType
final int getType()
Gets the type.- Returns:
- the type.
- Since:
- 6.0
-
stringifyValue
public abstract java.lang.String stringifyValue()
Returns a string representation of the element value.- Returns:
- a string representation of the element value.
-
toShortString
public java.lang.String toShortString()
Returns a short string representation of the element value.- Returns:
- a short string representation of the element value.
-
toString
public java.lang.String toString()
Returns a string representation of the element value.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of the element value.
-
-