Interface Output
- All Superinterfaces:
ByteOutput
- All Known Subinterfaces:
AnnotatedOutput
- All Known Implementing Classes:
ByteArrayAnnotatedOutput
Interface for a sink for binary output. This is similar to
java.util.DataOutput, but no IOExceptions
are declared, and multibyte output is defined to be little-endian.-
Method Summary
Modifier and TypeMethodDescriptionvoidalignTo(int alignment) Adds extra bytes if necessary (with value0) to force alignment of the output cursor as given.voidassertCursor(int expectedCursor) Asserts that the cursor is the given value.intGets the current cursor position.voidwrite(byte[] bytes) Writes abyte[]to this instance.voidwrite(byte[] bytes, int offset, int length) Writes a portion of abyte[]to this instance.voidWrites aByteArrayto this instance.voidwriteByte(int value) Writes abyteto this instance.voidwriteInt(int value) Writes anintto this instance.voidwriteLong(long value) Writes alongto this instance.voidwriteShort(int value) Writes ashortto this instance.intwriteSleb128(int value) Writes a DWARFv3-style unsigned LEB128 integer.intwriteUleb128(int value) Writes a DWARFv3-style unsigned LEB128 integer.voidwriteZeroes(int count) Writes the given number of0bytes.
-
Method Details
-
getCursor
int getCursor()Gets the current cursor position. This is the same as the number of bytes written to this instance.- Returns:
>= 0;the cursor position
-
assertCursor
void assertCursor(int expectedCursor) Asserts that the cursor is the given value.- Parameters:
expectedCursor- the expected cursor value- Throws:
RuntimeException- thrown ifgetCursor() != expectedCursor
-
writeByte
void writeByte(int value) Writes abyteto this instance.- Specified by:
writeBytein interfaceByteOutput- Parameters:
value- the value to write; all but the low 8 bits are ignored
-
writeShort
void writeShort(int value) Writes ashortto this instance.- Parameters:
value- the value to write; all but the low 16 bits are ignored
-
writeInt
void writeInt(int value) Writes anintto this instance.- Parameters:
value- the value to write
-
writeLong
void writeLong(long value) Writes alongto this instance.- Parameters:
value- the value to write
-
writeUleb128
int writeUleb128(int value) Writes a DWARFv3-style unsigned LEB128 integer. For details, see the "Dalvik Executable Format" document or DWARF v3 section 7.6.- Parameters:
value- value to write, treated as an unsigned value- Returns:
1..5;the number of bytes actually written
-
writeSleb128
int writeSleb128(int value) Writes a DWARFv3-style unsigned LEB128 integer. For details, see the "Dalvik Executable Format" document or DWARF v3 section 7.6.- Parameters:
value- value to write- Returns:
1..5;the number of bytes actually written
-
write
-
write
void write(byte[] bytes, int offset, int length) Writes a portion of abyte[]to this instance.- Parameters:
bytes-non-null;the array to writeoffset->= 0;offset intobytesfor the first byte to writelength->= 0;number of bytes to write
-
write
void write(byte[] bytes) Writes abyte[]to this instance. This is just a convenient shorthand forwrite(bytes, 0, bytes.length).- Parameters:
bytes-non-null;the array to write
-
writeZeroes
void writeZeroes(int count) Writes the given number of0bytes.- Parameters:
count->= 0;the number of zeroes to write
-
alignTo
void alignTo(int alignment) Adds extra bytes if necessary (with value0) to force alignment of the output cursor as given.- Parameters:
alignment-> 0;the alignment; must be a power of two
-