Class StdAttributeList

All Implemented Interfaces:
AttributeList, ToHuman

public final class StdAttributeList extends FixedSizeList implements AttributeList
Standard implementation of AttributeList, which directly stores an array of Attribute objects and can be made immutable.
  • Constructor Details

    • StdAttributeList

      public StdAttributeList(int size)
      Constructs an instance. All indices initially contain null.
      Parameters:
      size - the size of the list
  • Method Details

    • get

      public Attribute get(int n)
      Get the nth attribute.
      Specified by:
      get in interface AttributeList
      Parameters:
      n - n >= 0, n < size(); which attribute
      Returns:
      non-null; the attribute in question
    • byteLength

      public int byteLength()
      Get the total length of this list in bytes, when part of a class file. The returned value includes the two bytes for the attributes_count length indicator.
      Specified by:
      byteLength in interface AttributeList
      Returns:
      >= 2; the total length, in bytes
    • findFirst

      public Attribute findFirst(String name)
      Get the first attribute in the list with the given name, if any.
      Specified by:
      findFirst in interface AttributeList
      Parameters:
      name - non-null; attribute name
      Returns:
      null-ok; first attribute in the list with the given name, or null if there is none
    • findNext

      public Attribute findNext(Attribute attrib)
      Get the next attribute in the list after the given one, with the same name, if any.
      Specified by:
      findNext in interface AttributeList
      Parameters:
      attrib - non-null; attribute to start looking after
      Returns:
      null-ok; next attribute after attrib with the same name as attrib
    • set

      public void set(int n, Attribute attribute)
      Sets the attribute at the given index.
      Parameters:
      n - >= 0, < size(); which attribute
      attribute - null-ok; the attribute object