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

public final Class UniformListItem<T extends OffsettedItem>

extends OffsettedItem
Class Inheritance
Type Parameters
<T>
type of element contained in an instance
Imports
org.droidparts.dexmaker.dx.util.AnnotatedOutput, .Hex, java.util.List

Class that represents a contiguous list of uniform items. Each item in the list, in particular, must have the same write size and alignment.

This class inherits its alignment from its items, bumped up to 4 if the items have a looser alignment requirement. If it is more than 4, then there will be a gap after the output list size (which is four bytes) and before the first item.

Field Summary

Modifier and TypeField and Description
private static final int
HEADER_SIZE

the size of the list header

private final List<T>
items

non-null; the contents

private final ItemType
itemType

non-null; the item type

Constructor Summary

AccessConstructor and Description
public
UniformListItem(ItemType
non-null; the type of the item
itemType
,
List<T>
non-null and non-empty; list of items to represent
items
)

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.
private static int

Returns:

>= 4; the alignment requirement
getAlignment
(List<? extends OffsettedItem>
non-null; list of items being represented
items
)

Helper for UniformListItem, which returns the alignment requirement implied by the given list.

public final List<T>

Returns:

non-null; the list
getItems
()

Gets the underlying list of items.

private int

Returns:

>= 0; the header size
headerSize
()

Get the size of the header of this list.

public ItemType
itemType()

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

Returns the item type for this instance.
protected void
place0(Section
non-null; the section this instance has been added to
addedTo
,
int
>= 0; the offset from the start of the section where this instance was placed
offset
)

Overrides org.droidparts.dexmaker.dx.dex.file.OffsettedItem.place0.

Does additional work required when placing an instance.
public final String
toHuman()

Implements abstract org.droidparts.dexmaker.dx.dex.file.OffsettedItem.toHuman.

Gets a short human-readable string representing this instance.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private static int

Returns:

>= 0; the write size
writeSize
(List<? extends OffsettedItem>
non-null; the list in question
items
)

Calculates the write size for the given list.

protected void
writeTo0(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.OffsettedItem.writeTo0.

Performs the actual write of the contents of this instance to the given data section.
Inherited from org.droidparts.dexmaker.dx.dex.file.OffsettedItem:
compareTocompareTo0equalsgetAbsoluteOffsetgetAbsoluteOffsetOr0getAlignmentgetRelativeOffsetoffsetStringplacesetWriteSizewriteSizewriteTo

Field Detail

HEADER_SIZEback to summary
private static final int HEADER_SIZE

the size of the list header

itemsback to summary
private final List<T> items

non-null; the contents

itemTypeback to summary
private final ItemType itemType

non-null; the item type

Constructor Detail

UniformListItemback to summary
public UniformListItem(ItemType itemType, List<T> items)

Constructs an instance. It is illegal to modify the given list once it is used to construct an instance of this class.

Parameters
itemType:ItemType

non-null; the type of the item

items:List<T>

non-null and non-empty; list of items to represent

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
getAlignmentback to summary
private static int getAlignment(List<? extends OffsettedItem> items)

Helper for UniformListItem, which returns the alignment requirement implied by the given list. See the header comment for more details.

Parameters
items:List<? extends OffsettedItem>

non-null; list of items being represented

Returns:int

>= 4; the alignment requirement

getItemsback to summary
public final List<T> getItems()

Gets the underlying list of items.

Returns:List<T>

non-null; the list

headerSizeback to summary
private int headerSize()

Get the size of the header of this list.

Returns:int

>= 0; the header size

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
place0back to summary
protected void place0(Section addedTo, int offset)

Overrides org.droidparts.dexmaker.dx.dex.file.OffsettedItem.place0.

Doc from org.droidparts.dexmaker.dx.dex.file.OffsettedItem.place0.

Does additional work required when placing an instance. The default implementation of this method is a no-op. If a particular class needs to do something special, then it should override this method. In particular, if this instance did not know its write size up-front, then this method is responsible for setting it.

Parameters
addedTo:Section

non-null; the section this instance has been added to

offset:int

>= 0; the offset from the start of the section where this instance was placed

Annotations
@Override
toHumanback to summary
public final String toHuman()

Implements abstract org.droidparts.dexmaker.dx.dex.file.OffsettedItem.toHuman.

Doc from org.droidparts.dexmaker.dx.dex.file.OffsettedItem.toHuman.

Gets a short human-readable string representing this instance.

Returns:String

non-null; the human form

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
writeSizeback to summary
private static int writeSize(List<? extends OffsettedItem> items)

Calculates the write size for the given list.

Parameters
items:List<? extends OffsettedItem>

non-null; the list in question

Returns:int

>= 0; the write size

writeTo0back to summary
protected void writeTo0(DexFile file, AnnotatedOutput out)

Implements abstract org.droidparts.dexmaker.dx.dex.file.OffsettedItem.writeTo0.

Doc from org.droidparts.dexmaker.dx.dex.file.OffsettedItem.writeTo0.

Performs the actual write of the contents of this instance to the given data section. This is called by writeTo, which will have taken care of ensuring alignment.

Parameters
file:DexFile

non-null; the file to use for reference

out:AnnotatedOutput

non-null; where to write to

Annotations
@Override