Class ElementValueGen

java.lang.Object
org.apache.bcel.generic.ElementValueGen
Direct Known Subclasses:
AnnotationElementValueGen, ArrayElementValueGen, ClassElementValueGen, EnumElementValueGen, SimpleElementValueGen

public abstract class ElementValueGen extends Object
Generates element values in annotations.
Since:
6.0
  • Field Details

    • STRING

      public static final int STRING
      Element value type: string.
      See Also:
    • ENUM_CONSTANT

      public static final int ENUM_CONSTANT
      Element value type: enum constant.
      See Also:
    • CLASS

      public static final int CLASS
      Element value type: class.
      See Also:
    • ANNOTATION

      public static final int ANNOTATION
      Element value type: annotation.
      See Also:
    • ARRAY

      public static final int ARRAY
      Element value type: array.
      See Also:
    • PRIMITIVE_INT

      public static final int PRIMITIVE_INT
      Element value type: primitive int.
      See Also:
    • PRIMITIVE_BYTE

      public static final int PRIMITIVE_BYTE
      Element value type: primitive byte.
      See Also:
    • PRIMITIVE_CHAR

      public static final int PRIMITIVE_CHAR
      Element value type: primitive char.
      See Also:
    • PRIMITIVE_DOUBLE

      public static final int PRIMITIVE_DOUBLE
      Element value type: primitive double.
      See Also:
    • PRIMITIVE_FLOAT

      public static final int PRIMITIVE_FLOAT
      Element value type: primitive float.
      See Also:
    • PRIMITIVE_LONG

      public static final int PRIMITIVE_LONG
      Element value type: primitive long.
      See Also:
    • PRIMITIVE_SHORT

      public static final int PRIMITIVE_SHORT
      Element value type: primitive short.
      See Also:
    • PRIMITIVE_BOOLEAN

      public static final int PRIMITIVE_BOOLEAN
      Element value type: primitive boolean.
      See Also:
    • type

      @Deprecated protected int type
      Deprecated.
      (since 6.0) will be made private and final; do not access directly, use getter
    • cpGen

      @Deprecated protected ConstantPoolGen cpGen
      Deprecated.
      (since 6.0) will be made private and final; do not access directly, use getter
  • Constructor Details

    • ElementValueGen

      protected ElementValueGen(int type, ConstantPoolGen cpGen)
      Constructs an ElementValueGen.
      Parameters:
      type - The element value type.
      cpGen - The constant pool.
  • Method Details

    • copy

      public static ElementValueGen copy(ElementValue value, ConstantPoolGen cpool, boolean copyPoolEntries)
      Creates an (modifiable) ElementValueGen copy of an (immutable) ElementValue - constant pool is assumed correct.
      Parameters:
      value - The element value to copy.
      cpool - The constant pool generator.
      copyPoolEntries - whether to copy pool entries.
      Returns:
      A copy of the element value.
    • readElementValue

      public static ElementValueGen readElementValue(DataInput dis, ConstantPoolGen cpGen) throws IOException
      Reads an element value from a DataInput.
      Parameters:
      dis - The data input stream.
      cpGen - The constant pool.
      Returns:
      The element value read.
      Throws:
      IOException - Thrown if an I/O error occurs.
    • dump

      public abstract void dump(DataOutputStream dos) throws IOException
      Dumps this element value to a DataOutputStream.
      Parameters:
      dos - The output stream.
      Throws:
      IOException - Thrown if an I/O error occurs.
    • getConstantPool

      protected ConstantPoolGen getConstantPool()
      Gets the constant pool.
      Returns:
      The constant pool.
    • getElementValue

      public abstract ElementValue getElementValue()
      Subtypes return an immutable variant of the ElementValueGen.
      Returns:
      An immutable variant of the ElementValueGen.
    • getElementValueType

      public int getElementValueType()
      Gets the element value type.
      Returns:
      The element value type.
    • stringifyValue

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