Class ConstantValue


  • public class ConstantValue
    extends Attribute
    The ConstantValue attribute stores an index into the constant pool that represents constant value. A class's static fields have constant value attributes.
    See Also:
    Field
    • Constructor Summary

      Constructors 
      Constructor Description
      ConstantValue​(java.io.DataInputStream in, int nameIndex, int length)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()  
      int constantValueIndex()
      Returns the index into the constant pool of the constant value.
      void setConstantValueIndex​(int index)
      Set the index into the constant pool of the constant value.
      java.lang.String toString()
      Converts the attribute to a string.
      void writeData​(java.io.DataOutputStream out)
      Write the attribute to a data stream.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ConstantValue

        public ConstantValue​(java.io.DataInputStream in,
                             int nameIndex,
                             int length)
                      throws java.io.IOException
        Constructor. Create a ConstantValue attribute from a data stream.
        Parameters:
        in - The data stream of the class file.
        nameIndex - The index into the constant pool of the name of the attribute.
        length - The length of the attribute, excluding the header.
        Throws:
        java.io.IOException - If an error occurs while reading.
    • Method Detail

      • writeData

        public void writeData​(java.io.DataOutputStream out)
                       throws java.io.IOException
        Write the attribute to a data stream.
        Specified by:
        writeData in class Attribute
        Parameters:
        out - The data stream of the class file.
        Throws:
        java.io.IOException
      • constantValueIndex

        public int constantValueIndex()
        Returns the index into the constant pool of the constant value.
      • setConstantValueIndex

        public void setConstantValueIndex​(int index)
        Set the index into the constant pool of the constant value.
      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class Attribute
      • toString

        public java.lang.String toString()
        Converts the attribute to a string.
        Overrides:
        toString in class Attribute