public abstract class Section
extends java.lang.Object
.dex file. Each section consists of a list
of items of some sort or other.| Constructor and Description |
|---|
Section(java.lang.String name,
DexFile file,
int alignment)
Constructs an instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
align(AnnotatedOutput out)
Aligns the output of the given data to the alignment of this instance.
|
abstract int |
getAbsoluteItemOffset(Item item)
Returns the absolute file offset of the given item which must
be contained in this section.
|
int |
getAbsoluteOffset(int relative)
Returns the absolute file offset, given an offset from the
start of this instance's output.
|
int |
getAlignment()
Gets the alignment for this instance's final output.
|
DexFile |
getFile()
Gets the file that this instance is part of.
|
int |
getFileOffset()
Gets the offset from the start of the file to this part.
|
protected java.lang.String |
getName()
Returns the name of this section, for annotation purposes.
|
abstract java.util.Collection<? extends Item> |
items()
Gets the collection of all the items in this section.
|
void |
prepare()
Prepares this instance for writing.
|
protected abstract void |
prepare0()
Does the main work of
prepare(). |
int |
setFileOffset(int fileOffset)
Sets the file offset.
|
protected void |
throwIfNotPrepared()
Throws an exception if
prepare() has not been
called on this instance. |
protected void |
throwIfPrepared()
Throws an exception if
prepare() has already been called
on this instance. |
static void |
validateAlignment(int alignment)
Validates an alignment.
|
abstract int |
writeSize()
Gets the size of this instance when output, in bytes.
|
void |
writeTo(AnnotatedOutput out)
Writes this instance to the given raw data object.
|
protected abstract void |
writeTo0(AnnotatedOutput out)
Writes this instance to the given raw data object.
|
public Section(java.lang.String name,
DexFile file,
int alignment)
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 2public static void validateAlignment(int alignment)
alignment - the alignmentjava.lang.IllegalArgumentException - thrown if alignment
isn't a positive power of 2public final DexFile getFile()
non-null; the filepublic final int getAlignment()
> 0; the alignmentpublic final int getFileOffset()
>= 0; the file offsetpublic final int setFileOffset(int fileOffset)
fileOffset - >= 0; the desired offset from the start of the
file where this for this instance>= 0; the offset that this instance should be placed at
in order to meet its alignment constraintpublic final void writeTo(AnnotatedOutput out)
out - non-null; where to write topublic final int getAbsoluteOffset(int relative)
setFileOffset(int)).relative - >= 0; the relative offset>= 0; the corresponding absolute file offsetpublic abstract int getAbsoluteItemOffset(Item item)
setFileOffset(int)).
Note: Subclasses must implement this as appropriate for their contents.
item - non-null; the item in question>= 0; the item's absolute file offsetpublic final void prepare()
public abstract java.util.Collection<? extends Item> items()
non-null; the itemsprotected abstract void prepare0()
prepare().public abstract int writeSize()
>= 0; the size of this instance, in bytesprotected final void throwIfNotPrepared()
prepare() has not been
called on this instance.protected final void throwIfPrepared()
prepare() has already been called
on this instance.protected final void align(AnnotatedOutput out)
out - non-null; the output to alignprotected abstract void writeTo0(AnnotatedOutput out)
writeTo(com.android.dx.util.AnnotatedOutput) after aligning the cursor of
out and verifying that either the assigned file
offset matches the actual cursor out or that the
file offset was not previously assigned, in which case it gets
assigned to out's cursor.out - non-null; where to write toprotected final java.lang.String getName()
null-ok; name of this part, for annotation purposesCopyright © 2020. All Rights Reserved.