MapItempublic final class MapItem extends OffsettedItem Class that represents a map item. |
Fields Summary |
---|
private static final int | ALIGNMENTfile alignment of this class, in bytes | private static final int | WRITE_SIZEwrite size of this class, in bytes: three uint s | private final ItemType | typenon-null; item type this instance covers | private final Section | sectionnon-null; section this instance covers | private final Item | firstItemnull-ok; first item covered or null if this is
a self-reference | private final Item | lastItemnull-ok; last item covered or null if this is
a self-reference | private final int | itemCount> 0; count of items covered; 1 if this
is a self-reference |
Constructors Summary |
---|
private MapItem(ItemType type, Section section, Item firstItem, Item lastItem, int itemCount)Constructs an instance.
super(ALIGNMENT, WRITE_SIZE);
if (type == null) {
throw new NullPointerException("type == null");
}
if (section == null) {
throw new NullPointerException("section == null");
}
if (firstItem == null) {
throw new NullPointerException("firstItem == null");
}
if (lastItem == null) {
throw new NullPointerException("lastItem == null");
}
if (itemCount <= 0) {
throw new IllegalArgumentException("itemCount <= 0");
}
this.type = type;
this.section = section;
this.firstItem = firstItem;
this.lastItem = lastItem;
this.itemCount = itemCount;
| private MapItem(Section section)Constructs a self-referential instance. This instance is meant to
represent the section containing the map_list .
super(ALIGNMENT, WRITE_SIZE);
if (section == null) {
throw new NullPointerException("section == null");
}
this.type = ItemType.TYPE_MAP_LIST;
this.section = section;
this.firstItem = null;
this.lastItem = null;
this.itemCount = 1;
|
Methods Summary |
---|
public void | addContents(DexFile file){@inheritDoc}
// We have nothing to add.
| public static void | addMap(Section[] sections, MixedItemSection mapSection)Constructs a list item with instances of this class representing
the contents of the given array of sections, adding it to the
given map section.
if (sections == null) {
throw new NullPointerException("sections == null");
}
if (mapSection.items().size() != 0) {
throw new IllegalArgumentException(
"mapSection.items().size() != 0");
}
ArrayList<MapItem> items = new ArrayList<MapItem>(50);
for (Section section : sections) {
ItemType currentType = null;
Item firstItem = null;
Item lastItem = null;
int count = 0;
for (Item item : section.items()) {
ItemType type = item.itemType();
if (type != currentType) {
if (count != 0) {
items.add(new MapItem(currentType, section,
firstItem, lastItem, count));
}
currentType = type;
firstItem = item;
count = 0;
}
lastItem = item;
count++;
}
if (count != 0) {
// Add a MapItem for the final items in the section.
items.add(new MapItem(currentType, section,
firstItem, lastItem, count));
} else if (section == mapSection) {
// Add a MapItem for the self-referential section.
items.add(new MapItem(mapSection));
}
}
mapSection.add(
new UniformListItem<MapItem>(ItemType.TYPE_MAP_LIST, items));
| public ItemType | itemType(){@inheritDoc}
return ItemType.TYPE_MAP_ITEM;
| public final java.lang.String | toHuman(){@inheritDoc}
return toString();
| public java.lang.String | toString(){@inheritDoc}
StringBuffer sb = new StringBuffer(100);
sb.append(getClass().getName());
sb.append('{");
sb.append(section.toString());
sb.append(' ");
sb.append(type.toHuman());
sb.append('}");
return sb.toString();
| protected void | writeTo0(DexFile file, com.android.dx.util.AnnotatedOutput out){@inheritDoc}
int value = type.getMapValue();
int offset;
if (firstItem == null) {
offset = section.getFileOffset();
} else {
offset = section.getAbsoluteItemOffset(firstItem);
}
if (out.annotates()) {
out.annotate(0, offsetString() + ' " + type.getTypeName() +
" map");
out.annotate(2, " type: " + Hex.u2(value) + " // " +
type.toString());
out.annotate(2, " unused: 0");
out.annotate(4, " size: " + Hex.u4(itemCount));
out.annotate(4, " offset: " + Hex.u4(offset));
}
out.writeShort(value);
out.writeShort(0); // unused
out.writeInt(itemCount);
out.writeInt(offset);
|
|