Class ClassReader.AttrIterator

java.lang.Object
com.ibm.wala.shrike.shrikeCT.ClassReader.AttrIterator
Enclosing class:
ClassReader

public static final class ClassReader.AttrIterator extends Object
AttrIterator provides access to attributes in the class file.

AttrIterators can be reused for many different iterations, like this:

   AttrIterator iter = new AttrIterator();
    int fieldCount = reader.getFieldCount();
    for (int i = 0; i < fieldCount; i++) {
      reader.initFieldAttributeIterator(i, iter);
      for (; iter.isValid(); iter.advance()) {
        if (iter.getName().equals("ConstantValue")) {
          ConstantValueReader cv = new ConstantValueReader(iter);
          ...
        }
      }
    }
 
  • Constructor Details

    • AttrIterator

      public AttrIterator()
      Create a blank iterator. The iterator is not valid until it is initialized by some other class.
  • Method Details

    • getClassReader

      public ClassReader getClassReader()
    • getRawOffset

      public int getRawOffset()
      The attribute iterator must be valid.
      Returns:
      the offset of the raw attribute data (including attribute header) in the class file data
    • getRawSize

      public int getRawSize()
      The attribute iterator must be valid.
      Returns:
      the size of the raw attribute data (including attribute header) in the class file data
    • getDataOffset

      public int getDataOffset()
      The attribute iterator must be valid.
      Returns:
      the offset of the attribute data (excluding attribute header) in the class file data
    • getDataSize

      public int getDataSize()
      The attribute iterator must be valid.
      Returns:
      the size of the attribute data (excluding attribute header) in the class file data
    • getRemainingAttributesCount

      public int getRemainingAttributesCount()
      Returns:
      the number of attributes left in the list, including this attribute (if valid)
    • getNameIndex

      public int getNameIndex()
      The attribute iterator must be valid.
      Returns:
      the constant pool index of the name of the attribute
    • getName

      public String getName() throws InvalidClassFileException
      The attribute iterator must be valid.
      Returns:
      the name of the attribute
      Throws:
      InvalidClassFileException
    • isValid

      public boolean isValid()
      Returns:
      whether this iterator is valid
    • advance

      public void advance()
      The attribute iterator must be valid.

      The iterator is advanced to the next attribute (which might not exist, so the iterator might become invalid).