ElementValue (Apache Tomcat 11.0.24 API Documentation)
Description: declaration: package: org.apache.tomcat.util.bcel.classfile, class: ElementValue

# Class ElementValue

java.lang.Object
org.apache.tomcat.util.bcel.classfile.ElementValue

Direct Known Subclasses:
  `AnnotationElementValue, ArrayElementValue, ClassElementValue, EnumElementValue, SimpleElementValue`

public abstract class ElementValue extends Object
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;
    }

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final byte`
  `ANNOTATION`
  Tag for an annotation element value.
  `static final byte`
  `ARRAY`
  Tag for an array element value.
  `static final byte`
  `CLASS`
  Tag for a class element value.
  `static final byte`
  `ENUM_CONSTANT`
  Tag for an enum constant element value.
  `static final byte`
  `PRIMITIVE_BOOLEAN`
  Tag for a boolean primitive element value.
  `static final byte`
  `PRIMITIVE_BYTE`
  Tag for a byte primitive element value.
  `static final byte`
  `PRIMITIVE_CHAR`
  Tag for a char primitive element value.
  `static final byte`
  `PRIMITIVE_DOUBLE`
  Tag for a double primitive element value.
  `static final byte`
  `PRIMITIVE_FLOAT`
  Tag for a float primitive element value.
  `static final byte`
  `PRIMITIVE_INT`
  Tag for an int primitive element value.
  `static final byte`
  `PRIMITIVE_LONG`
  Tag for a long primitive element value.
  `static final byte`
  `PRIMITIVE_SHORT`
  Tag for a short primitive element value.
  `static final byte`
  `STRING`
  Tag for a String element value.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ElementValue`
  `readElementValue(DataInput input, ConstantPool cpool)`
  Reads an `element_value` as an `ElementValue`.
  `static ElementValue`
  `readElementValue(DataInput input, ConstantPool cpool, int arrayNesting)`
  Reads an `element_value` as an `ElementValue`.
  `abstract String`
  `stringifyValue()`
  Returns a string representation of this element value.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### STRING

    public static final byte STRING
    Tag for a String element value.
    See Also:
      - Constant Field Values

  - ### ENUM_CONSTANT

    public static final byte ENUM_CONSTANT
    Tag for an enum constant element value.
    See Also:
      - Constant Field Values

  - ### CLASS

    public static final byte CLASS
    Tag for a class element value.
    See Also:
      - Constant Field Values

  - ### ANNOTATION

    public static final byte ANNOTATION
    Tag for an annotation element value.
    See Also:
      - Constant Field Values

  - ### ARRAY

    public static final byte ARRAY
    Tag for an array element value.
    See Also:
      - Constant Field Values

  - ### PRIMITIVE_INT

    public static final byte PRIMITIVE_INT
    Tag for an int primitive element value.
    See Also:
      - Constant Field Values

  - ### PRIMITIVE_BYTE

    public static final byte PRIMITIVE_BYTE
    Tag for a byte primitive element value.
    See Also:
      - Constant Field Values

  - ### PRIMITIVE_CHAR

    public static final byte PRIMITIVE_CHAR
    Tag for a char primitive element value.
    See Also:
      - Constant Field Values

  - ### PRIMITIVE_DOUBLE

    public static final byte PRIMITIVE_DOUBLE
    Tag for a double primitive element value.
    See Also:
      - Constant Field Values

  - ### PRIMITIVE_FLOAT

    public static final byte PRIMITIVE_FLOAT
    Tag for a float primitive element value.
    See Also:
      - Constant Field Values

  - ### PRIMITIVE_LONG

    public static final byte PRIMITIVE_LONG
    Tag for a long primitive element value.
    See Also:
      - Constant Field Values

  - ### PRIMITIVE_SHORT

    public static final byte PRIMITIVE_SHORT
    Tag for a short primitive element value.
    See Also:
      - Constant Field Values

  - ### PRIMITIVE_BOOLEAN

    public static final byte PRIMITIVE_BOOLEAN
    Tag for a boolean primitive element value.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### readElementValue

    public static ElementValue readElementValue(DataInput input, ConstantPool cpool) throws IOException
    Reads an `element_value` as an `ElementValue`.
    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 an `element_value` as an `ElementValue`.
    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

  - ### stringifyValue

    public abstract String stringifyValue()
    Returns a string representation of this element value.
    Returns:
      the string representation