Class Attribute

java.lang.Object
EDU.purdue.cs.bloat.file.Attribute
Direct Known Subclasses:
Code, ConstantValue, Exceptions, GenericAttribute, LineNumberTable, LocalVariableTable

public abstract class Attribute extends Object
Attribute is an abstract class for an attribute defined for a method, field, or class. An attribute consists of its name (represented as an index into the constant pool) and its length. Attribute is extended to represent a constant value, code, exceptions, etc.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
     
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Attribute(int nameIndex, int length)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    int
    Returns the length of the attribute, excluding the header.
    int
    Returns the index into the constant pool of the name of the attribute.
    Returns a string representation of the attribute.
    abstract void
    Write the attribute to a data stream.

    Methods inherited from class Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • nameIndex

      protected int nameIndex
    • length

      protected int length
  • Constructor Details

    • Attribute

      public Attribute(int nameIndex, int length)
      Constructor.
      Parameters:
      nameIndex - The index into the constant pool of the name of the attribute.
      length - The length of the attribute, excluding the header.
  • Method Details

    • writeData

      public abstract void writeData(DataOutputStream out) throws IOException
      Write the attribute to a data stream.
      Parameters:
      out - The data stream of the class file.
      Throws:
      IOException
    • toString

      public String toString()
      Returns a string representation of the attribute.
      Overrides:
      toString in class Object
    • nameIndex

      public int nameIndex()
      Returns the index into the constant pool of the name of the attribute.
    • length

      public int length()
      Returns the length of the attribute, excluding the header.
    • clone

      public Object clone()
      Overrides:
      clone in class Object