Package com.android.dx.util
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 TypeMethodDescriptionvoid
alignTo
(int alignment) Adds extra bytes if necessary (with value0
) to force alignment of the output cursor as given.void
assertCursor
(int expectedCursor) Asserts that the cursor is the given value.int
Gets the current cursor position.void
write
(byte[] bytes) Writes abyte[]
to this instance.void
write
(byte[] bytes, int offset, int length) Writes a portion of abyte[]
to this instance.void
Writes aByteArray
to this instance.void
writeByte
(int value) Writes abyte
to this instance.void
writeInt
(int value) Writes anint
to this instance.void
writeLong
(long value) Writes along
to this instance.void
writeShort
(int value) Writes ashort
to this instance.int
writeSleb128
(int value) Writes a DWARFv3-style unsigned LEB128 integer.int
writeUleb128
(int value) Writes a DWARFv3-style unsigned LEB128 integer.void
writeZeroes
(int count) Writes the given number of0
bytes.
-
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 abyte
to this instance.- Specified by:
writeByte
in interfaceByteOutput
- Parameters:
value
- the value to write; all but the low 8 bits are ignored
-
writeShort
void writeShort(int value) Writes ashort
to this instance.- Parameters:
value
- the value to write; all but the low 16 bits are ignored
-
writeInt
void writeInt(int value) Writes anint
to this instance.- Parameters:
value
- the value to write
-
writeLong
void writeLong(long value) Writes along
to 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
Writes aByteArray
to this instance.- Parameters:
bytes
-non-null;
the array to 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 intobytes
for 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 of0
bytes.- 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
-