Methods Summary |
---|
private void | checkOffsets(int s, int e)Checks a range of offsets for validity, throwing if invalid.
if ((s < 0) || (e < s) || (e > size)) {
throw new IllegalArgumentException("bad range: " + s + ".." + e +
"; actual size " + size);
}
|
public int | getByte(int off)Gets the signed byte value at a particular offset.
checkOffsets(off, off + 1);
return getByte0(off);
|
private int | getByte0(int off)Gets the signed byte value at the given offset,
without doing any argument checking.
return bytes[start + off];
|
public void | getBytes(byte[] out, int offset)Copies the contents of this instance into the given raw
byte[] at the given offset. The given array must be
large enough.
if ((out.length - offset) < size) {
throw new IndexOutOfBoundsException("(out.length - offset) < " +
"size()");
}
System.arraycopy(bytes, start, out, offset, size);
|
public int | getInt(int off)Gets the signed int value at a particular offset.
checkOffsets(off, off + 4);
return (getByte0(off) << 24) |
(getUnsignedByte0(off + 1) << 16) |
(getUnsignedByte0(off + 2) << 8) |
getUnsignedByte0(off + 3);
|
public long | getLong(int off)Gets the signed long value at a particular offset.
checkOffsets(off, off + 8);
int part1 = (getByte0(off) << 24) |
(getUnsignedByte0(off + 1) << 16) |
(getUnsignedByte0(off + 2) << 8) |
getUnsignedByte0(off + 3);
int part2 = (getByte0(off + 4) << 24) |
(getUnsignedByte0(off + 5) << 16) |
(getUnsignedByte0(off + 6) << 8) |
getUnsignedByte0(off + 7);
return (part2 & 0xffffffffL) | ((long) part1) << 32;
|
public int | getShort(int off)Gets the signed short value at a particular offset.
checkOffsets(off, off + 2);
return (getByte0(off) << 8) | getUnsignedByte0(off + 1);
|
public int | getUnsignedByte(int off)Gets the unsigned byte value at a particular offset.
checkOffsets(off, off + 1);
return getUnsignedByte0(off);
|
private int | getUnsignedByte0(int off)Gets the unsigned byte value at the given offset,
without doing any argument checking.
return bytes[start + off] & 0xff;
|
public int | getUnsignedShort(int off)Gets the unsigned short value at a particular offset.
checkOffsets(off, off + 2);
return (getUnsignedByte0(off) << 8) | getUnsignedByte0(off + 1);
|
public com.android.dx.util.ByteArray$MyDataInputStream | makeDataInputStream()Gets a DataInputStream that reads from this instance,
with the cursor starting at the beginning of this instance's data.
Note: The returned instance may be cast to {@link #GetCursor}
if needed.
return new MyDataInputStream(makeInputStream());
|
public com.android.dx.util.ByteArray$MyInputStream | makeInputStream()Gets a InputStream that reads from this instance,
with the cursor starting at the beginning of this instance's data.
Note: The returned instance may be cast to {@link #GetCursor}
if needed.
return new MyInputStream();
|
public int | size()Gets the size of the array, in bytes.
return size;
|
public com.android.dx.util.ByteArray | slice(int start, int end)Returns a slice (that is, a sub-array) of this instance.
checkOffsets(start, end);
return new ByteArray(bytes, start + this.start, end + this.start);
|
public int | underlyingOffset(int offset, byte[] bytes)Returns the offset into the given array represented by the given
offset into this instance.
if (bytes != this.bytes) {
throw new IllegalArgumentException("wrong bytes");
}
return start + offset;
|