Class ElementValue
java.lang.Object
org.apache.bcel.classfile.ElementValue
- Direct Known Subclasses:
AnnotationElementValue, ArrayElementValue, ClassElementValue, EnumElementValue, SimpleElementValue
The element_value structure is documented at https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.16.1
element_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
FieldsModifier and TypeFieldDescriptionstatic final byteElement value type: annotation.static final byteElement value type: array.static final byteElement value type: class.protected ConstantPoolDeprecated.(since 6.0) will be made private and final; do not access directly, use getter.static final byteElement value type: enum constant.static final byteElement value type: primitive boolean.static final byteElement value type: primitive byte.static final byteElement value type: primitive char.static final byteElement value type: primitive double.static final byteElement value type: primitive float.static final byteElement value type: primitive int.static final byteElement value type: primitive long.static final byteElement value type: primitive short.static final byteElement value type: string.protected intDeprecated.(since 6.0) will be made private and final; do not access directly, use getter. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedElementValue(int type, ConstantPool cpool) Constructs an ElementValue. -
Method Summary
Modifier and TypeMethodDescriptionabstract voiddump(DataOutputStream dos) Dumps this element value to a DataOutputStream.intGets the element value type.static ElementValuereadElementValue(DataInput input, ConstantPool cpool) Reads anelement_valueas anElementValue.static ElementValuereadElementValue(DataInput input, ConstantPool cpool, int arrayNesting) Reads anelement_valueas anElementValue.abstract StringReturns a string representation of the element value.Returns a short string representation of the element value.toString()Returns a string representation of the element value.
-
Field Details
-
STRING
-
ENUM_CONSTANT
-
CLASS
-
ANNOTATION
-
ARRAY
-
PRIMITIVE_INT
-
PRIMITIVE_BYTE
-
PRIMITIVE_CHAR
-
PRIMITIVE_DOUBLE
-
PRIMITIVE_FLOAT
-
PRIMITIVE_LONG
-
PRIMITIVE_SHORT
-
PRIMITIVE_BOOLEAN
-
type
Deprecated.(since 6.0) will be made private and final; do not access directly, use getter. -
cpool
Deprecated.(since 6.0) will be made private and final; do not access directly, use getter.
-
-
Constructor Details
-
ElementValue
Constructs an ElementValue.- Parameters:
type- the element value type.cpool- the constant pool.
-
-
Method Details
-
readElementValue
Reads anelement_valueas anElementValue.- Parameters:
input- Raw data input.cpool- Constant pool.- Returns:
- a new ElementValue.
- Throws:
IOException- if an I/O error occurs.
-
readElementValue
public static ElementValue readElementValue(DataInput input, ConstantPool cpool, int arrayNesting) throws IOException Reads anelement_valueas anElementValue.- Parameters:
input- Raw data input.cpool- Constant pool.arrayNesting- level of current array nesting.- Returns:
- a new ElementValue.
- Throws:
IOException- if an I/O error occurs.- Since:
- 6.7.0
-
dump
Dumps this element value to a DataOutputStream.- Parameters:
dos- the output stream.- Throws:
IOException- if an I/O error occurs.
-
getElementValueType
-
stringifyValue
Returns a string representation of the element value.- Returns:
- a string representation of the element value.
-
toShortString
Returns a short string representation of the element value.- Returns:
- a short string representation of the element value.
-
toString
-