Package com.android.dx.dex.file
Class UniformItemSection
java.lang.Object
com.android.dx.dex.file.Section
com.android.dx.dex.file.UniformItemSection
- Direct Known Subclasses:
CallSiteIdsSection
,ClassDefsSection
,HeaderSection
,MemberIdsSection
,MethodHandlesSection
,ProtoIdsSection
,StringIdsSection
,TypeIdsSection
A section of a
.dex
file which consists of a sequence of
Item
objects. Each of the items must have the same size in
the output.-
Constructor Summary
ConstructorDescriptionUniformItemSection
(String name, DexFile file, int alignment) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionabstract IndexedItem
Gets the item corresponding to the givenConstant
.final int
getAbsoluteItemOffset
(Item item) Returns the absolute file offset of the given item which must be contained in this section.protected abstract void
Alters or picks the order for items in this instance if desired, so that subsequent calls toSection.items()
will yield a so-ordered collection.protected final void
prepare0()
Does the main work ofSection.prepare()
.final int
Gets the size of this instance when output, in bytes.protected final void
writeTo0
(AnnotatedOutput out) Writes this instance to the given raw data object.Methods inherited from class com.android.dx.dex.file.Section
align, getAbsoluteOffset, getAlignment, getFile, getFileOffset, getName, items, prepare, setFileOffset, throwIfNotPrepared, throwIfPrepared, validateAlignment, writeTo
-
Constructor Details
-
UniformItemSection
Constructs an instance. The file offset is initially unknown.- Parameters:
name
-null-ok;
the name of this instance, for annotation purposesfile
-non-null;
file that this instance is part ofalignment
-> 0;
alignment requirement for the final output; must be a power of 2
-
-
Method Details
-
writeSize
public final int writeSize()Gets the size of this instance when output, in bytes. -
get
Gets the item corresponding to the givenConstant
. This will throw an exception if the constant is not found, including if this instance isn't the sort that maps constants toIndexedItem
instances.- Parameters:
cst
-non-null;
constant to look for- Returns:
non-null;
the corresponding item found in this instance
-
prepare0
protected final void prepare0()Does the main work ofSection.prepare()
. -
writeTo0
Writes this instance to the given raw data object. This gets called bySection.writeTo(com.android.dx.util.AnnotatedOutput)
after aligning the cursor ofout
and verifying that either the assigned file offset matches the actual cursorout
or that the file offset was not previously assigned, in which case it gets assigned toout
's cursor. -
getAbsoluteItemOffset
Returns the absolute file offset of the given item which must be contained in this section. This is only valid to call once this instance has been assigned a file offset (viaSection.setFileOffset(int)
).Note: Subclasses must implement this as appropriate for their contents.
- Specified by:
getAbsoluteItemOffset
in classSection
- Parameters:
item
-non-null;
the item in question- Returns:
>= 0;
the item's absolute file offset
-
orderItems
protected abstract void orderItems()Alters or picks the order for items in this instance if desired, so that subsequent calls toSection.items()
will yield a so-ordered collection. If the items in this instance are indexed, then this method should also assign indices.
-