Methods Summary |
---|
public final int | compareTo(com.android.dx.dex.file.OffsettedItem other){@inheritDoc}
Comparisons for this class are defined to be class-major (if the
classes don't match then the objects are not equal), with
{@link #compareTo0} deciding same-class comparisons.
if (this == other) {
return 0;
}
ItemType thisType = itemType();
ItemType otherType = other.itemType();
if (thisType != otherType) {
return thisType.compareTo(otherType);
}
return compareTo0(other);
|
protected int | compareTo0(com.android.dx.dex.file.OffsettedItem other)Compares this instance to another which is guaranteed to be of
the same class. The default implementation of this method is to
throw an exception (unsupported operation). If a particular
class needs to actually sort, then it should override this
method.
throw new UnsupportedOperationException("unsupported");
|
public final boolean | equals(java.lang.Object other){@inheritDoc}
Comparisons for this class are defined to be type-major (if the
types don't match then the objects are not equal), with
{@link #compareTo0} deciding same-type comparisons.
if (this == other) {
return true;
}
OffsettedItem otherItem = (OffsettedItem) other;
ItemType thisType = itemType();
ItemType otherType = otherItem.itemType();
if (thisType != otherType) {
return false;
}
return (compareTo0(otherItem) == 0);
|
public final int | getAbsoluteOffset()Gets the absolute item offset. The offset is from the start of
the file which the instance was written to.
if (offset < 0) {
throw new RuntimeException("offset not yet known");
}
return addedTo.getAbsoluteOffset(offset);
|
public static int | getAbsoluteOffsetOr0(com.android.dx.dex.file.OffsettedItem item)Gets the absolute offset of the given item, returning {@code 0}
if handed {@code null}.
if (item == null) {
return 0;
}
return item.getAbsoluteOffset();
|
public final int | getAlignment()Gets the alignment requirement of this instance. An instance should
only be written when so aligned.
return alignment;
|
public final int | getRelativeOffset()Gets the relative item offset. The offset is from the start of
the section which the instance was written to.
if (offset < 0) {
throw new RuntimeException("offset not yet known");
}
return offset;
|
public final java.lang.String | offsetString()Gets the absolute offset of this item as a string, suitable for
including in annotations.
return '[" + Integer.toHexString(getAbsoluteOffset()) + ']";
|
public final int | place(Section addedTo, int offset)Indicates that this item has been added to the given section at
the given offset. It is only valid to call this method once per
instance.
if (addedTo == null) {
throw new NullPointerException("addedTo == null");
}
if (offset < 0) {
throw new IllegalArgumentException("offset < 0");
}
if (this.addedTo != null) {
throw new RuntimeException("already written");
}
int mask = alignment - 1;
offset = (offset + mask) & ~mask;
this.addedTo = addedTo;
this.offset = offset;
place0(addedTo, offset);
return offset;
|
protected void | place0(Section addedTo, int offset)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.
// This space intentionally left blank.
|
public final void | setWriteSize(int writeSize)Sets the write size of this item. This may only be called once
per instance, and only if the size was unknown upon instance
creation.
if (writeSize < 0) {
throw new IllegalArgumentException("writeSize < 0");
}
if (this.writeSize >= 0) {
throw new UnsupportedOperationException("writeSize already set");
}
this.writeSize = writeSize;
|
public abstract java.lang.String | toHuman()Gets a short human-readable string representing this instance.
|
public final int | writeSize(){@inheritDoc}
if (writeSize < 0) {
throw new UnsupportedOperationException("writeSize is unknown");
}
return writeSize;
|
public final void | writeTo(DexFile file, com.android.dx.util.AnnotatedOutput out){@inheritDoc}
out.alignTo(alignment);
try {
if (writeSize < 0) {
throw new UnsupportedOperationException(
"writeSize is unknown");
}
out.assertCursor(getAbsoluteOffset());
} catch (RuntimeException ex) {
throw ExceptionWithContext.withContext(ex,
"...while writing " + this);
}
writeTo0(file, out);
|
protected abstract void | writeTo0(DexFile file, com.android.dx.util.AnnotatedOutput out)Performs the actual write of the contents of this instance to
the given data section. This is called by {@link #writeTo},
which will have taken care of ensuring alignment.
|