Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.dex.file

public final Class ClassDefItem

extends IndexedItem
Class Inheritance
Imports
org.droidparts.dexmaker.dx.dex.SizeOf, org.droidparts.dexmaker.dx.rop.annotation.Annotations, .AnnotationsList, org.droidparts.dexmaker.dx.rop.code.AccessFlags, org.droidparts.dexmaker.dx.rop.cst.*, org.droidparts.dexmaker.dx.rop.type.StdTypeList, .TypeList, org.droidparts.dexmaker.dx.util.AnnotatedOutput, .Hex, .Writers, java.io.PrintWriter, .Writer, java.util.ArrayList

Representation of a Dalvik class, which is basically a set of members (fields or methods) along with a few more pieces of information.

Field Summary

Modifier and TypeField and Description
private final int
accessFlags

access flags

private AnnotationsDirectoryItem
annotationsDirectory

non-null; annotations directory

private final ClassDataItem
classData

non-null; associated class data object

private TypeListItem
interfaces

null-ok; list of implemented interfaces

private final CstString
sourceFile

null-ok; source file name or null if unknown

private EncodedArrayItem
staticValuesItem

null-ok; item wrapper for the static values, initialized in addContents

private final CstType
superclass

null-ok; superclass or null if this class is a/the root class

private final CstType
thisClass

non-null; type constant for this class

Constructor Summary

AccessConstructor and Description
public
ClassDefItem(CstType
non-null; type constant for this class
thisClass
,
int
access flags
accessFlags
,
CstType
null-ok; superclass or null if this class is a/the root class
superclass
,
TypeList
non-null; list of implemented interfaces
interfaces
,
CstString
null-ok; source file name or null if unknown
sourceFile
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public void
addContents(DexFile
non-null; the file to populate
file
)

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.addContents.

Populates a DexFile with items from within this instance.
public void
addDirectMethod(EncodedMethod
non-null; the method to add
method
)

Adds a direct (static and/or private) method.

public void
addFieldAnnotations(CstFieldRef
non-null; field in question
field
,
Annotations
non-null; associated annotations to add
annotations
)

Adds a field annotations item to this class.

public void
addInstanceField(EncodedField
non-null; the field to add
field
)

Adds an instance field.

public void
addMethodAnnotations(CstMethodRef
non-null; method in question
method
,
Annotations
non-null; associated annotations to add
annotations
)

Adds a method annotations item to this class.

public void
addParameterAnnotations(CstMethodRef
non-null; method in question
method
,
AnnotationsList
non-null; associated list of annotation sets to add
list
)

Adds a parameter annotations item to this class.

public void
addStaticField(EncodedField
non-null; the field to add
field
,
Constant
null-ok; initial value for the field, if any
value
)

Adds a static field.

public void
addVirtualMethod(EncodedMethod
non-null; the method to add
method
)

Adds a virtual method.

public void
debugPrint(Writer
non-null; where to output to
out
,
boolean
whether to be verbose with the output
verbose
)

Prints out the contents of this instance, in a debugging-friendly way.

public int

Returns:

the access flags
getAccessFlags
()

Gets the access flags.

public TypeList

Returns:

non-null; the interfaces list
getInterfaces
()

Gets the list of interfaces implemented.

public Annotations

Returns:

null-ok; the method annotations, if any
getMethodAnnotations
(CstMethodRef
non-null; the method
method
)

Gets the method annotations for a given method, if any.

public ArrayList<EncodedMethod>

Returns:

non-null; list of all methods
getMethods
()

Gets all the methods in this class.

public AnnotationsList

Returns:

null-ok; the parameter annotations, if any
getParameterAnnotations
(CstMethodRef
non-null; the method
method
)

Gets the parameter annotations for a given method, if any.

public CstString

Returns:

null-ok; the source file name or null if unknown
getSourceFile
()

Gets the source file name.

public CstType

Returns:

null-ok; the superclass or null if this class is a/the root class
getSuperclass
()

Gets the superclass.

public CstType

Returns:

non-null; the constant
getThisClass
()

Gets the constant corresponding to this class.

public ItemType
itemType()

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.itemType.

Returns the item type for this instance.
public void
setClassAnnotations(Annotations
non-null; annotations to set for this class
annotations
)

Sets the direct annotations on this class.

public int
writeSize()

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.writeSize.

Gets the size of this instance when written, in bytes.
public void
writeTo(DexFile
non-null; the file to use for reference
file
,
AnnotatedOutput
non-null; where to write to
out
)

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.writeTo.

Writes the representation of this instance to the given data section, using the given DexFile to look things up as needed.
Inherited from org.droidparts.dexmaker.dx.dex.file.IndexedItem:
getIndexhasIndexindexStringsetIndex

Field Detail

accessFlagsback to summary
private final int accessFlags

access flags

annotationsDirectoryback to summary
private AnnotationsDirectoryItem annotationsDirectory

non-null; annotations directory

classDataback to summary
private final ClassDataItem classData

non-null; associated class data object

interfacesback to summary
private TypeListItem interfaces

null-ok; list of implemented interfaces

sourceFileback to summary
private final CstString sourceFile

null-ok; source file name or null if unknown

staticValuesItemback to summary
private EncodedArrayItem staticValuesItem

null-ok; item wrapper for the static values, initialized in addContents

superclassback to summary
private final CstType superclass

null-ok; superclass or null if this class is a/the root class

thisClassback to summary
private final CstType thisClass

non-null; type constant for this class

Constructor Detail

ClassDefItemback to summary
public ClassDefItem(CstType thisClass, int accessFlags, CstType superclass, TypeList interfaces, CstString sourceFile)

Constructs an instance. Its sets of members and annotations are initially empty.

Parameters
thisClass:CstType

non-null; type constant for this class

accessFlags:int

access flags

superclass:CstType

null-ok; superclass or null if this class is a/the root class

interfaces:TypeList

non-null; list of implemented interfaces

sourceFile:CstString

null-ok; source file name or null if unknown

Method Detail

addContentsback to summary
public void addContents(DexFile file)

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.addContents.

Doc from org.droidparts.dexmaker.dx.dex.file.Item.addContents.

Populates a DexFile with items from within this instance. This will not add an item to the file for this instance itself (which should have been done by whatever refers to this instance).

Note

Subclasses must override this to do something appropriate.

Parameters
file:DexFile

non-null; the file to populate

Annotations
@Override
addDirectMethodback to summary
public void addDirectMethod(EncodedMethod method)

Adds a direct (static and/or private) method.

Parameters
method:EncodedMethod

non-null; the method to add

addFieldAnnotationsback to summary
public void addFieldAnnotations(CstFieldRef field, Annotations annotations)

Adds a field annotations item to this class.

Parameters
field:CstFieldRef

non-null; field in question

annotations:Annotations

non-null; associated annotations to add

addInstanceFieldback to summary
public void addInstanceField(EncodedField field)

Adds an instance field.

Parameters
field:EncodedField

non-null; the field to add

addMethodAnnotationsback to summary
public void addMethodAnnotations(CstMethodRef method, Annotations annotations)

Adds a method annotations item to this class.

Parameters
method:CstMethodRef

non-null; method in question

annotations:Annotations

non-null; associated annotations to add

addParameterAnnotationsback to summary
public void addParameterAnnotations(CstMethodRef method, AnnotationsList list)

Adds a parameter annotations item to this class.

Parameters
method:CstMethodRef

non-null; method in question

list:AnnotationsList

non-null; associated list of annotation sets to add

addStaticFieldback to summary
public void addStaticField(EncodedField field, Constant value)

Adds a static field.

Parameters
field:EncodedField

non-null; the field to add

value:Constant

null-ok; initial value for the field, if any

addVirtualMethodback to summary
public void addVirtualMethod(EncodedMethod method)

Adds a virtual method.

Parameters
method:EncodedMethod

non-null; the method to add

debugPrintback to summary
public void debugPrint(Writer out, boolean verbose)

Prints out the contents of this instance, in a debugging-friendly way.

Parameters
out:Writer

non-null; where to output to

verbose:boolean

whether to be verbose with the output

getAccessFlagsback to summary
public int getAccessFlags()

Gets the access flags.

Returns:int

the access flags

getInterfacesback to summary
public TypeList getInterfaces()

Gets the list of interfaces implemented.

Returns:TypeList

non-null; the interfaces list

getMethodAnnotationsback to summary
public Annotations getMethodAnnotations(CstMethodRef method)

Gets the method annotations for a given method, if any. This is meant for use by debugging / dumping code.

Parameters
method:CstMethodRef

non-null; the method

Returns:Annotations

null-ok; the method annotations, if any

getMethodsback to summary
public ArrayList<EncodedMethod> getMethods()

Gets all the methods in this class. The returned list is not linked in any way to the underlying lists contained in this instance, but the objects contained in the list are shared.

Returns:ArrayList<EncodedMethod>

non-null; list of all methods

getParameterAnnotationsback to summary
public AnnotationsList getParameterAnnotations(CstMethodRef method)

Gets the parameter annotations for a given method, if any. This is meant for use by debugging / dumping code.

Parameters
method:CstMethodRef

non-null; the method

Returns:AnnotationsList

null-ok; the parameter annotations, if any

getSourceFileback to summary
public CstString getSourceFile()

Gets the source file name.

Returns:CstString

null-ok; the source file name or null if unknown

getSuperclassback to summary
public CstType getSuperclass()

Gets the superclass.

Returns:CstType

null-ok; the superclass or null if this class is a/the root class

getThisClassback to summary
public CstType getThisClass()

Gets the constant corresponding to this class.

Returns:CstType

non-null; the constant

itemTypeback to summary
public ItemType itemType()

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.itemType.

Doc from org.droidparts.dexmaker.dx.dex.file.Item.itemType.

Returns the item type for this instance.

Returns:ItemType

non-null; the item type

Annotations
@Override
setClassAnnotationsback to summary
public void setClassAnnotations(Annotations annotations)

Sets the direct annotations on this class. These are annotations made on the class, per se, as opposed to on one of its members. It is only valid to call this method at most once per instance.

Parameters
annotations:Annotations

non-null; annotations to set for this class

writeSizeback to summary
public int writeSize()

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.writeSize.

Doc from org.droidparts.dexmaker.dx.dex.file.Item.writeSize.

Gets the size of this instance when written, in bytes.

Returns:int

>= 0; the write size

Annotations
@Override
writeToback to summary
public void writeTo(DexFile file, AnnotatedOutput out)

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.writeTo.

Doc from org.droidparts.dexmaker.dx.dex.file.Item.writeTo.

Writes the representation of this instance to the given data section, using the given DexFile to look things up as needed. If this instance keeps track of its offset, then this method will note the written offset and will also throw an exception if this instance has already been written.

Parameters
file:DexFile

non-null; the file to use for reference

out:AnnotatedOutput

non-null; where to write to

Annotations
@Override