Class ConstantValue

java.lang.Object
EDU.purdue.cs.bloat.file.Attribute
EDU.purdue.cs.bloat.file.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:
  • Constructor Details

    • ConstantValue

      public ConstantValue(DataInputStream in, int nameIndex, int length) throws 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:
      IOException - If an error occurs while reading.
  • Method Details

    • writeData

      public void writeData(DataOutputStream out) throws IOException
      Write the attribute to a data stream.
      Specified by:
      writeData in class Attribute
      Parameters:
      out - The data stream of the class file.
      Throws:
      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 Object clone()
      Overrides:
      clone in class Attribute
    • toString

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