Class AttributeFactory

java.lang.Object
com.android.dx.cf.direct.AttributeFactory
Direct Known Subclasses:
StdAttributeFactory

public class AttributeFactory extends Object
Factory capable of instantiating various Attribute subclasses depending on the context and name.
  • Field Details

    • CTX_CLASS

      public static final int CTX_CLASS
      context for attributes on class files
      See Also:
    • CTX_FIELD

      public static final int CTX_FIELD
      context for attributes on fields
      See Also:
    • CTX_METHOD

      public static final int CTX_METHOD
      context for attributes on methods
      See Also:
    • CTX_CODE

      public static final int CTX_CODE
      context for attributes on code attributes
      See Also:
    • CTX_COUNT

      public static final int CTX_COUNT
      number of contexts
      See Also:
  • Constructor Details

    • AttributeFactory

      public AttributeFactory()
      Constructs an instance.
  • Method Details

    • parse

      public final Attribute parse(DirectClassFile cf, int context, int offset, ParseObserver observer)
      Parses and makes an attribute based on the bytes at the indicated position in the given array. This method figures out the name, and then does all the setup to call on to parse0(com.android.dx.cf.direct.DirectClassFile, int, java.lang.String, int, int, com.android.dx.cf.iface.ParseObserver), which does the actual construction.
      Parameters:
      cf - non-null; class file to parse from
      context - context to parse in; one of the CTX_* constants
      offset - offset into dcf's bytes to start parsing at
      observer - null-ok; parse observer to report to, if any
      Returns:
      non-null; an appropriately-constructed Attribute
    • parse0

      protected Attribute parse0(DirectClassFile cf, int context, String name, int offset, int length, ParseObserver observer)
      Parses attribute content. The base class implements this by constructing an instance of RawAttribute. Subclasses are expected to override this to do something better in most cases.
      Parameters:
      cf - non-null; class file to parse from
      context - context to parse in; one of the CTX_* constants
      name - non-null; the attribute name
      offset - offset into bytes to start parsing at; this is the offset to the start of attribute data, not to the header
      length - the length of the attribute data
      observer - null-ok; parse observer to report to, if any
      Returns:
      non-null; an appropriately-constructed Attribute