/** * Constructs an instance. It is illegal to modify the given list once * it is used to construct an instance of this class. * * @param itemType {@code non-null;} the type of the item * @param items {@code non-null and non-empty;} list of items to represent */ public UniformListItem(ItemType itemType, List<T> items) { super(getAlignment(items), writeSize(items)); if (itemType == null) { throw new NullPointerException("itemType == null"); } this.items = items; this.itemType = itemType; }
/** {@inheritDoc} */ public String toHuman() { StringBuilder sb = new StringBuilder(); sb.append(method.toHuman()); sb.append(": "); boolean first = true; for (AnnotationSetRefItem item : annotationsItem.getItems()) { if (first) { first = false; } else { sb.append(", "); } sb.append(item.toHuman()); } return sb.toString(); }
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { int size = items.size(); if (out.annotates()) { out.annotate(0, offsetString() + " " + typeName()); out.annotate(4, " size: " + Hex.u4(size)); } out.writeInt(size); for (OffsettedItem i : items) { i.writeTo(file, out); } }
/** * Get the size of the header of this list. * * @return {@code >= 0;} the header size */ private int headerSize() { /* * Because of how this instance was set up, this is the same * as the alignment. */ return getAlignment(); } }
this.annotationsItem = new UniformListItem<AnnotationSetRefItem>( ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList);
/** {@inheritDoc} */ public void writeTo(DexFile file, AnnotatedOutput out) { int methodIdx = file.getMethodIds().indexOf(method); int annotationsOff = annotationsItem.getAbsoluteOffset(); if (out.annotates()) { out.annotate(0, " " + method.toHuman()); out.annotate(4, " method_idx: " + Hex.u4(methodIdx)); out.annotate(4, " annotations_off: " + Hex.u4(annotationsOff)); } out.writeInt(methodIdx); out.writeInt(annotationsOff); }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { offset += headerSize(); boolean first = true; int theSize = -1; int theAlignment = -1; for (OffsettedItem i : items) { int size = i.writeSize(); if (first) { theSize = size; theAlignment = i.getAlignment(); first = false; } else { if (size != theSize) { throw new UnsupportedOperationException( "item size mismatch"); } if (i.getAlignment() != theAlignment) { throw new UnsupportedOperationException( "item alignment mismatch"); } } offset = i.place(addedTo, offset) + size; } }
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { int size = items.size(); if (out.annotates()) { out.annotate(0, offsetString() + " " + typeName()); out.annotate(4, " size: " + Hex.u4(size)); } out.writeInt(size); for (OffsettedItem i : items) { i.writeTo(file, out); } }
/** * Get the size of the header of this list. * * @return {@code >= 0;} the header size */ private int headerSize() { /* * Because of how this instance was set up, this is the same * as the alignment. */ return getAlignment(); } }
this.annotationsItem = new UniformListItem<AnnotationSetRefItem>( ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList);
/** {@inheritDoc} */ public void writeTo(DexFile file, AnnotatedOutput out) { int methodIdx = file.getMethodIds().indexOf(method); int annotationsOff = annotationsItem.getAbsoluteOffset(); if (out.annotates()) { out.annotate(0, " " + method.toHuman()); out.annotate(4, " method_idx: " + Hex.u4(methodIdx)); out.annotate(4, " annotations_off: " + Hex.u4(annotationsOff)); } out.writeInt(methodIdx); out.writeInt(annotationsOff); }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { offset += headerSize(); boolean first = true; int theSize = -1; int theAlignment = -1; for (OffsettedItem i : items) { int size = i.writeSize(); if (first) { theSize = size; theAlignment = i.getAlignment(); first = false; } else { if (size != theSize) { throw new UnsupportedOperationException( "item size mismatch"); } if (i.getAlignment() != theAlignment) { throw new UnsupportedOperationException( "item alignment mismatch"); } } offset = i.place(addedTo, offset) + size; } }
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { int size = items.size(); if (out.annotates()) { out.annotate(0, offsetString() + " " + typeName()); out.annotate(4, " size: " + Hex.u4(size)); } out.writeInt(size); for (OffsettedItem i : items) { i.writeTo(file, out); } }
/** * Constructs an instance. It is illegal to modify the given list once * it is used to construct an instance of this class. * * @param itemType {@code non-null;} the type of the item * @param items {@code non-null and non-empty;} list of items to represent */ public UniformListItem(ItemType itemType, List<T> items) { super(getAlignment(items), writeSize(items)); if (itemType == null) { throw new NullPointerException("itemType == null"); } this.items = items; this.itemType = itemType; }
/** * Get the size of the header of this list. * * @return {@code >= 0;} the header size */ private int headerSize() { /* * Because of how this instance was set up, this is the same * as the alignment. */ return getAlignment(); } }
this.annotationsItem = new UniformListItem<AnnotationSetRefItem>( ItemType.TYPE_ANNOTATION_SET_REF_LIST, arrayList);
/** {@inheritDoc} */ public void writeTo(DexFile file, AnnotatedOutput out) { int methodIdx = file.getMethodIds().indexOf(method); int annotationsOff = annotationsItem.getAbsoluteOffset(); if (out.annotates()) { out.annotate(0, " " + method.toHuman()); out.annotate(4, " method_idx: " + Hex.u4(methodIdx)); out.annotate(4, " annotations_off: " + Hex.u4(annotationsOff)); } out.writeInt(methodIdx); out.writeInt(annotationsOff); }
/** {@inheritDoc} */ @Override public String toHuman() { StringBuilder sb = new StringBuilder(); sb.append(method.toHuman()); sb.append(": "); boolean first = true; for (AnnotationSetRefItem item : annotationsItem.getItems()) { if (first) { first = false; } else { sb.append(", "); } sb.append(item.toHuman()); } return sb.toString(); }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { offset += headerSize(); boolean first = true; int theSize = -1; int theAlignment = -1; for (OffsettedItem i : items) { int size = i.writeSize(); if (first) { theSize = size; theAlignment = i.getAlignment(); first = false; } else { if (size != theSize) { throw new UnsupportedOperationException( "item size mismatch"); } if (i.getAlignment() != theAlignment) { throw new UnsupportedOperationException( "item alignment mismatch"); } } offset = i.place(addedTo, offset) + size; } }
/** {@inheritDoc} */ @Override protected void writeTo0(DexFile file, AnnotatedOutput out) { int size = items.size(); if (out.annotates()) { out.annotate(0, offsetString() + " " + typeName()); out.annotate(4, " size: " + Hex.u4(size)); } out.writeInt(size); for (OffsettedItem i : items) { i.writeTo(file, out); } }