Package com.android.dx.cf.direct
Class AttributeFactory
java.lang.Object
com.android.dx.cf.direct.AttributeFactory
- Direct Known Subclasses:
StdAttributeFactory
Factory capable of instantiating various
Attribute
subclasses
depending on the context and name.-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
context for attributes on class filesstatic final int
context for attributes on code attributesstatic final int
number of contextsstatic final int
context for attributes on fieldsstatic final int
context for attributes on methods -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal 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.protected Attribute
parse0
(DirectClassFile cf, int context, String name, int offset, int length, ParseObserver observer) Parses attribute content.
-
Field Details
-
CTX_CLASS
public static final int CTX_CLASScontext for attributes on class files- See Also:
-
CTX_FIELD
public static final int CTX_FIELDcontext for attributes on fields- See Also:
-
CTX_METHOD
public static final int CTX_METHODcontext for attributes on methods- See Also:
-
CTX_CODE
public static final int CTX_CODEcontext for attributes on code attributes- See Also:
-
CTX_COUNT
public static final int CTX_COUNTnumber of contexts- See Also:
-
-
Constructor Details
-
AttributeFactory
public AttributeFactory()Constructs an instance.
-
-
Method Details
-
parse
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 toparse0(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 fromcontext
- context to parse in; one of theCTX_*
constantsoffset
- offset intodcf
'sbytes
to start parsing atobserver
-null-ok;
parse observer to report to, if any- Returns:
non-null;
an appropriately-constructedAttribute
-
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 ofRawAttribute
. Subclasses are expected to override this to do something better in most cases.- Parameters:
cf
-non-null;
class file to parse fromcontext
- context to parse in; one of theCTX_*
constantsname
-non-null;
the attribute nameoffset
- offset intobytes
to start parsing at; this is the offset to the start of attribute data, not to the headerlength
- the length of the attribute dataobserver
-null-ok;
parse observer to report to, if any- Returns:
non-null;
an appropriately-constructedAttribute
-