AnnotatedOutput which stores the written data
into a byte[].Note
As per the Output interface, multi-byte
writes all use little-endian order.
| Modifier and Type | Class and Description |
|---|---|
| private static class | ByteArrayAnnotatedOutput.
Annotation on output. |
| Modifier and Type | Field and Description |
|---|---|
| private ArrayList | annotations
|
| private int | annotationWidth
|
| private int | cursor
|
| private byte[] | data
|
| private static final int | DEFAULT_SIZE
default size for stretchy instances |
| private int | hexCols
|
| private final boolean | stretchy
whether the instance is stretchy, that is, whether its array may be resized to increase capacity |
| private boolean | verbose
whether annotations are to be verbose |
| Access | Constructor and Description |
|---|---|
| public | ByteArrayAnnotatedOutput(byte[]
non-null; data array to use for outputConstructs an instance with a fixed maximum size. |
| public | |
| public | |
| private | ByteArrayAnnotatedOutput(byte[]
non-null; data array to use for outputwhether the instance is to be stretchy stretchy)Internal constructor. |
| Modifier and Type | Method and Description |
|---|---|
| public void | alignTo(int
> 0; the alignment; must be a power of twoImplements org. 0) to
force alignment of the output cursor as given.
|
| public void | annotate(String
non-null; the annotation messageImplements org. |
| public void | annotate(int
>= 0; the amount of output for this annotation to
covernon-null; the annotation messageImplements org. |
| public boolean | annotates()
Implements org. |
| public void | assertCursor(int
the expected cursor value expectedCursor)Implements org. |
| public void | enableAnnotations(int
>= 40; the desired maximum annotation widthwhether or not to indicate verbose annotations verbose)Indicates that this instance should keep annotations. |
| public void | endAnnotation()
Implements org. |
| private void | ensureCapacity(int
>= 0; the desired minimum total size of the arrayReallocates the underlying array if necessary. |
| public void | |
| public int | getAnnotationWidth()
Implements org. |
| public byte[] | Returns: non-null; the byte[]Gets the underlying |
| public int | getCursor()
Implements org. |
| public boolean | isVerbose()
Implements org. |
| private static void | throwBounds()
Throws the excpetion for when an attempt is made to write past the end of the instance. |
| public byte[] | Returns: non-null; an appropriately-constructed arrayConstructs and returns a new |
| public void | write(ByteArray
non-null; the array to writeImplements org. ByteArray to this instance.
|
| public void | write(byte[]
non-null; the array to write>= 0; offset into bytes for the first
byte to write>= 0; number of bytes to writeImplements org. byte[] to this instance.
|
| public void | write(byte[]
non-null; the array to writeImplements org. byte[] to this instance.
|
| public void | writeAnnotationsTo(Writer
non-null; where to write toWrites the annotated content of this instance to the given writer. |
| public void | writeByte(int
the value to write; all but the low 8 bits are ignored value)Implements org. |
| public void | writeInt(int
the value to write value)Implements org. int to this instance.
|
| public void | writeLong(long
the value to write value)Implements org. long to this instance.
|
| public void | writeShort(int
the value to write; all but the low 16 bits are ignored value)Implements org. short to this instance.
|
| public int | writeSleb128(int
value to write value)Implements org. |
| public int | writeUleb128(int
value to write, treated as an unsigned value value)Implements org. |
| public void | writeZeroes(int
>= 0; the number of zeroes to writeImplements org. 0 bytes.
|
| annotations | back to summary |
|---|---|
| private ArrayList<ByteArrayAnnotatedOutput.
| |
| annotationWidth | back to summary |
|---|---|
| private int annotationWidth
| |
| cursor | back to summary |
|---|---|
| private int cursor
| |
| data | back to summary |
|---|---|
| private byte[] data
| |
| DEFAULT_SIZE | back to summary |
|---|---|
| private static final int DEFAULT_SIZE default size for stretchy instances | |
| hexCols | back to summary |
|---|---|
| private int hexCols
| |
| stretchy | back to summary |
|---|---|
| private final boolean stretchy whether the instance is stretchy, that is, whether its array may be resized to increase capacity | |
| verbose | back to summary |
|---|---|
| private boolean verbose whether annotations are to be verbose | |
| ByteArrayAnnotatedOutput | back to summary |
|---|---|
| public ByteArrayAnnotatedOutput(byte[] data) Constructs an instance with a fixed maximum size. Note that the given array is the only one that will be used to store data. In particular, no reallocation will occur in order to expand the capacity of the resulting instance. Also, the constructed instance does not keep annotations by default.
| |
| ByteArrayAnnotatedOutput | back to summary |
|---|---|
| public ByteArrayAnnotatedOutput() Constructs a "stretchy" instance. The underlying array may be reallocated. The constructed instance does not keep annotations by default. | |
| ByteArrayAnnotatedOutput | back to summary |
|---|---|
| public ByteArrayAnnotatedOutput(int size) Constructs a "stretchy" instance with initial size | |
| ByteArrayAnnotatedOutput | back to summary |
|---|---|
| private ByteArrayAnnotatedOutput(byte[] data, boolean stretchy) Internal constructor.
| |
| alignTo | back to summary |
|---|---|
| public void alignTo(int alignment) Implements org. Doc from org. Adds extra bytes if necessary (with value
| |
| annotate | back to summary |
|---|---|
| public void annotate(String msg) Implements org. Doc from org. Add an annotation for the subsequent output. Any previously open annotation will be closed by this call, and the new annotation marks all subsequent output until another annotation call.
| |
| annotate | back to summary |
|---|---|
| public void annotate(int amt, String msg) Implements org. Doc from org. Add an annotation for a specified amount of subsequent output. Any previously open annotation will be closed by this call. If there is already pending annotation from one or more previous calls to this method, the new call "consumes" output after all the output covered by the previous calls.
| |
| annotates | back to summary |
|---|---|
| public boolean annotates() Implements org. Doc from org. Get whether this instance will actually keep annotations.
| |
| assertCursor | back to summary |
|---|---|
| public void assertCursor(int expectedCursor) Implements org. Doc from org. Asserts that the cursor is the given value.
| |
| enableAnnotations | back to summary |
|---|---|
| public void enableAnnotations(int annotationWidth, boolean verbose) Indicates that this instance should keep annotations. This method may be called only once per instance, and only before any data has been written to the it.
| |
| endAnnotation | back to summary |
|---|---|
| public void endAnnotation() Implements org. Doc from org. End the most recent annotation. Subsequent output will be unannotated,
until the next call to | |
| ensureCapacity | back to summary |
|---|---|
| private void ensureCapacity(int desiredSize) Reallocates the underlying array if necessary. Calls to this method
should be guarded by a test of
| |
| finishAnnotating | back to summary |
|---|---|
| public void finishAnnotating() Finishes up annotation processing. This closes off any open annotations and removes annotations that don't refer to written data. | |
| getAnnotationWidth | back to summary |
|---|---|
| public int getAnnotationWidth() Implements org. Doc from org. Get the maximum width of the annotated output. This is advisory: Implementations of this interface are encouraged to deal with too-wide output, but annotaters are encouraged to attempt to avoid exceeding the indicated width.
| |
| getArray | back to summary |
|---|---|
| public byte[] getArray() Gets the underlying
| |
| getCursor | back to summary |
|---|---|
| public int getCursor() Implements org. Doc from org. Gets the current cursor position. This is the same as the number of bytes written to this instance.
| |
| isVerbose | back to summary |
|---|---|
| public boolean isVerbose() Implements org. Doc from org. Get whether this instance is intended to keep verbose annotations. Annotators may use the result of calling this method to inform their annotation activity.
| |
| throwBounds | back to summary |
|---|---|
| private static void throwBounds() Throws the excpetion for when an attempt is made to write past the end of the instance. | |
| toByteArray | back to summary |
|---|---|
| public byte[] toByteArray() Constructs and returns a new
| |
| write | back to summary |
|---|---|
| public void write(ByteArray bytes) Implements org. Doc from org. Writes a
| |
| write | back to summary |
|---|---|
| public void write(byte[] bytes, int offset, int length) Implements org. Doc from org. Writes a portion of a
| |
| write | back to summary |
|---|---|
| public void write(byte[] bytes) Implements org. Doc from org. Writes a
| |
| writeAnnotationsTo | back to summary |
|---|---|
| public void writeAnnotationsTo(Writer out) throws IOException Writes the annotated content of this instance to the given writer.
| |
| writeByte | back to summary |
|---|---|
| public void writeByte(int value) Implements org. Doc from org. Writes a byte.
| |
| writeInt | back to summary |
|---|---|
| public void writeInt(int value) Implements org. Doc from org. Writes an
| |
| writeLong | back to summary |
|---|---|
| public void writeLong(long value) Implements org. Doc from org. Writes a
| |
| writeShort | back to summary |
|---|---|
| public void writeShort(int value) Implements org. Doc from org. Writes a
| |
| writeSleb128 | back to summary |
|---|---|
| public int writeSleb128(int value) Implements org. Doc from org. Writes a DWARFv3-style unsigned LEB128 integer. For details, see the "Dalvik Executable Format" document or DWARF v3 section 7.6.
| |
| writeUleb128 | back to summary |
|---|---|
| public int writeUleb128(int value) Implements org. Doc from org. Writes a DWARFv3-style unsigned LEB128 integer. For details, see the "Dalvik Executable Format" document or DWARF v3 section 7.6.
| |
| writeZeroes | back to summary |
|---|---|
| public void writeZeroes(int count) Implements org. Doc from org. Writes the given number of
| |
| Modifier and Type | Field and Description |
|---|---|
| private int | end
|
| private final int | start
|
| private final String | text
|
| Access | Constructor and Description |
|---|---|
| public | Annotation(int
>= 0; start of annotated range>= start; end of annotated range (exclusive) or
Integer.MAX_VALUE if unclosednon-null; annotation textConstructs an instance. |
| public | Annotation(int
>= 0; start of annotated rangenon-null; annotation textConstructs an instance. |
| Modifier and Type | Method and Description |
|---|---|
| public int | |
| public int | |
| public String | |
| public void | |
| public void | setEndIfUnset(int
>= start; the endSets the end as given, but only if the instance is unclosed; otherwise, do nothing. |
| end | back to summary |
|---|---|
| private int end
| |
| start | back to summary |
|---|---|
| private final int start
| |
| text | back to summary |
|---|---|
| private final String text
| |
| Annotation | back to summary |
|---|---|
| public Annotation(int start, int end, String text) Constructs an instance.
| |
| Annotation | back to summary |
|---|---|
| public Annotation(int start, String text) Constructs an instance. It is initally unclosed.
| |
| getEnd | back to summary |
|---|---|
| public int getEnd() Gets the end.
| |
| getStart | back to summary |
|---|---|
| public int getStart() Gets the start.
| |
| getText | back to summary |
|---|---|
| public String getText() Gets the text.
| |
| setEnd | back to summary |
|---|---|
| public void setEnd(int end) Sets the end as given.
| |
| setEndIfUnset | back to summary |
|---|---|
| public void setEndIfUnset(int end) Sets the end as given, but only if the instance is unclosed; otherwise, do nothing.
| |