com.android.dx.cf.direct
Class AttributeFactory

java.lang.Object
  extended by 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 Summary
static int CTX_CLASS
          context for attributes on class files
static int CTX_CODE
          context for attributes on code attributes
static int CTX_COUNT
          number of contexts
static int CTX_FIELD
          context for attributes on fields
static int CTX_METHOD
          context for attributes on methods
 
Constructor Summary
AttributeFactory()
          Constructs an instance.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CTX_CLASS

public static final int CTX_CLASS
context for attributes on class files

See Also:
Constant Field Values

CTX_FIELD

public static final int CTX_FIELD
context for attributes on fields

See Also:
Constant Field Values

CTX_METHOD

public static final int CTX_METHOD
context for attributes on methods

See Also:
Constant Field Values

CTX_CODE

public static final int CTX_CODE
context for attributes on code attributes

See Also:
Constant Field Values

CTX_COUNT

public static final int CTX_COUNT
number of contexts

See Also:
Constant Field Values
Constructor Detail

AttributeFactory

public AttributeFactory()
Constructs an instance.

Method Detail

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


Copyright © 2015. All rights reserved.