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

public final Class ClassDefsSection

extends UniformItemSection
Class Inheritance
Imports
org.droidparts.dexmaker.dx.rop.cst.Constant, .CstType, org.droidparts.dexmaker.dx.rop.type.Type, .TypeList, org.droidparts.dexmaker.dx.util.AnnotatedOutput, .Hex, java.util.ArrayList, .Collection, .TreeMap

Class definitions list section of a .dex file.

Field Summary

Modifier and TypeField and Description
private final TreeMap<Type, ClassDefItem>
classDefs

non-null; map from type constants for classes to ClassDefItem instances that define those classes

private ArrayList<ClassDefItem>
orderedDefs

null-ok; ordered list of classes; set in orderItems

Constructor Summary

AccessConstructor and Description
public
ClassDefsSection(DexFile
non-null; file that this instance is part of
file
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public void
add(ClassDefItem
non-null; the class def to add
clazz
)

Adds an element to this instance.

public IndexedItem
get(Constant
non-null; constant to look for
cst
)

Implements abstract org.droidparts.dexmaker.dx.dex.file.UniformItemSection.get.

Gets the item corresponding to the given Constant.
public Collection<? extends Item>
items()

Implements abstract org.droidparts.dexmaker.dx.dex.file.Section.items.

Gets the collection of all the items in this section.
protected void
orderItems()

Implements abstract org.droidparts.dexmaker.dx.dex.file.UniformItemSection.orderItems.

Alters or picks the order for items in this instance if desired, so that subsequent calls to items will yield a so-ordered collection.
private int

Returns:

>= 0; the next index to assign
orderItems0
(Type
null-ok; type ref to assign, if any
type
,
int
>= 0; the next index to assign
idx
,
int
maximum recursion depth; if negative, this will throw an exception indicating class definition circularity
maxDepth
)

Helper for orderItems, which recursively assigns indices to classes.

public void
writeHeaderPart(AnnotatedOutput
non-null; where to write
out
)

Writes the portion of the file header that refers to this instance.

Inherited from org.droidparts.dexmaker.dx.dex.file.UniformItemSection:
getAbsoluteItemOffsetprepare0writeSizewriteTo0

Field Detail

classDefsback to summary
private final TreeMap<Type, ClassDefItem> classDefs

non-null; map from type constants for classes to ClassDefItem instances that define those classes

orderedDefsback to summary
private ArrayList<ClassDefItem> orderedDefs

null-ok; ordered list of classes; set in orderItems

Constructor Detail

ClassDefsSectionback to summary
public ClassDefsSection(DexFile file)

Constructs an instance. The file offset is initially unknown.

Parameters
file:DexFile

non-null; file that this instance is part of

Method Detail

addback to summary
public void add(ClassDefItem clazz)

Adds an element to this instance. It is illegal to attempt to add more than one class with the same name.

Parameters
clazz:ClassDefItem

non-null; the class def to add

getback to summary
public IndexedItem get(Constant cst)

Implements abstract org.droidparts.dexmaker.dx.dex.file.UniformItemSection.get.

Doc from org.droidparts.dexmaker.dx.dex.file.UniformItemSection.get.

Gets the item corresponding to the given Constant. This will throw an exception if the constant is not found, including if this instance isn't the sort that maps constants to IndexedItem instances.

Parameters
cst:Constant

non-null; constant to look for

Returns:IndexedItem

non-null; the corresponding item found in this instance

Annotations
@Override
itemsback to summary
public Collection<? extends Item> items()

Implements abstract org.droidparts.dexmaker.dx.dex.file.Section.items.

Doc from org.droidparts.dexmaker.dx.dex.file.Section.items.

Gets the collection of all the items in this section. It is not valid to attempt to change the returned list.

Returns:Collection<? extends Item>

non-null; the items

Annotations
@Override
orderItemsback to summary
protected void orderItems()

Implements abstract org.droidparts.dexmaker.dx.dex.file.UniformItemSection.orderItems.

Doc from org.droidparts.dexmaker.dx.dex.file.UniformItemSection.orderItems.

Alters or picks the order for items in this instance if desired, so that subsequent calls to items will yield a so-ordered collection. If the items in this instance are indexed, then this method should also assign indices.

Annotations
@Override
orderItems0back to summary
private int orderItems0(Type type, int idx, int maxDepth)

Helper for orderItems, which recursively assigns indices to classes.

Parameters
type:Type

null-ok; type ref to assign, if any

idx:int

>= 0; the next index to assign

maxDepth:int

maximum recursion depth; if negative, this will throw an exception indicating class definition circularity

Returns:int

>= 0; the next index to assign

writeHeaderPartback to summary
public void writeHeaderPart(AnnotatedOutput out)

Writes the portion of the file header that refers to this instance.

Parameters
out:AnnotatedOutput

non-null; where to write