byte[], which provides read-only access and
can "reveal" a partial slice of the underlying arrayNote
Multibyte accessors all use big-endian order.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | ByteArray.
Helper interface that allows one to get the cursor (of a stream). |
| public static class | ByteArray.
Helper class for |
| public class | ByteArray.
Helper class for |
| Modifier and Type | Field and Description |
|---|---|
| private final byte[] | bytes
|
| private final int | size
|
| private final int | start
|
| Access | Constructor and Description |
|---|---|
| public | ByteArray(byte[]
non-null; the underlying array>= 0; start index of the slice (inclusive)>= start, <= bytes.length; end index of
the slice (exclusive)Constructs an instance. |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | checkOffsets(int
start offset (inclusive) s, int end offset (exclusive) e)Checks a range of offsets for validity, throwing if invalid. |
| public int | Returns: signed byte at that offset>= 0, < size(); offset to fetchGets the |
| private int | Returns: byte at that offsetoffset to fetch off)Gets the |
| public void | getBytes(byte[]
non-null; array to hold the outputnon-null; index into out for the first
byte of outputCopies the contents of this instance into the given raw
|
| public int | Returns: signed int at that offset>= 0, < (size() - 3); offset to fetchGets the |
| public long | Returns: signed int at that offset>= 0, < (size() - 7); offset to fetchGets the |
| public int | Returns: signed short at that offset>= 0, < (size() - 1); offset to fetchGets the |
| public int | Returns: unsigned byte at that offset>= 0, < size(); offset to fetchGets the |
| private int | Returns: byte at that offsetoffset to fetch off)Gets the |
| public int | Returns: unsigned short at that offset>= 0, < (size() - 1); offset to fetchGets the |
| public ByteArray. | Returns: non-null; an appropriately-constructed
DataInputStream instanceGets a Note The returned instance may be cast to |
| public ByteArray. | Returns: non-null; an appropriately-constructed
InputStream instancexGets a Note The returned instance may be cast to |
| public int | |
| public ByteArray | Returns: non-null; the slice>= 0; start index of the slice (inclusive)>= start, <= size(); end index of
the slice (exclusive)Returns a slice (that is, a sub-array) of this instance. |
| public int | Returns: corresponding offset intobytesoffset into this instance offset, byte[] non-null; (alleged) underlying arrayReturns the offset into the given array represented by the given offset into this instance. |
| bytes | back to summary |
|---|---|
| private final byte[] bytes
| |
| size | back to summary |
|---|---|
| private final int size
| |
| start | back to summary |
|---|---|
| private final int start
| |
| ByteArray | back to summary |
|---|---|
| public ByteArray(byte[] bytes, int start, int end) Constructs an instance.
| |
| ByteArray | back to summary |
|---|---|
| public ByteArray(byte[] bytes) Constructs an instance from an entire
| |
| checkOffsets | back to summary |
|---|---|
| private void checkOffsets(int s, int e) Checks a range of offsets for validity, throwing if invalid.
| |
| getByte | back to summary |
|---|---|
| public int getByte(int off) Gets the
| |
| getByte0 | back to summary |
|---|---|
| private int getByte0(int off) Gets the
| |
| getBytes | back to summary |
|---|---|
| public void getBytes(byte[] out, int offset) Copies the contents of this instance into the given raw
| |
| getInt | back to summary |
|---|---|
| public int getInt(int off) Gets the
| |
| getLong | back to summary |
|---|---|
| public long getLong(int off) Gets the
| |
| getShort | back to summary |
|---|---|
| public int getShort(int off) Gets the
| |
| getUnsignedByte | back to summary |
|---|---|
| public int getUnsignedByte(int off) Gets the
| |
| getUnsignedByte0 | back to summary |
|---|---|
| private int getUnsignedByte0(int off) Gets the
| |
| getUnsignedShort | back to summary |
|---|---|
| public int getUnsignedShort(int off) Gets the
| |
| makeDataInputStream | back to summary |
|---|---|
| public ByteArray. Gets a Note The returned instance may be cast to
| |
| makeInputStream | back to summary |
|---|---|
| public ByteArray. Gets a Note The returned instance may be cast to
| |
| size | back to summary |
|---|---|
| public int size() Gets the size of the array, in bytes.
| |
| slice | back to summary |
|---|---|
| public ByteArray slice(int start, int end) Returns a slice (that is, a sub-array) of this instance.
| |
| underlyingOffset | back to summary |
|---|---|
| public int underlyingOffset(int offset, byte[] bytes) Returns the offset into the given array represented by the given offset into this instance.
| |
| Modifier and Type | Method and Description |
|---|---|
| public int |
| getCursor | back to summary |
|---|---|
| public int getCursor() Gets the current cursor.
| |
makeDataInputStream. This is used
simply so that the cursor of a wrapped MyInputStream
instance may be easily determined.
| Modifier and Type | Field and Description |
|---|---|
| private final ByteArray. | wrapped
|
| Access | Constructor and Description |
|---|---|
| public |
| wrapped | back to summary |
|---|---|
| private final ByteArray.
| |
| MyDataInputStream | back to summary |
|---|---|
| public MyDataInputStream(ByteArray. | |
makeInputStream, which implements the
stream functionality.
| Modifier and Type | Field and Description |
|---|---|
| private int | cursor
0..size; the cursor |
| private int | mark
0..size; the mark |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | available()
Overrides java. |
| public void | mark(int
the maximum limit of bytes that can be read before
the mark position becomes invalid. reserve)Overrides java. |
| public boolean | markSupported()
Overrides java. mark and
reset methods.
|
| public int | read()
Implements abstract java. |
| public int | read(byte[]
the buffer into which the data is read. arr, int the start offset in array offset, int b
at which the data is written.the maximum number of bytes to read. length)Overrides java. len bytes of data from the input stream into
an array of bytes.
|
| public void | reset()
Overrides java. mark method was last called on this input stream.
|
| cursor | back to summary |
|---|---|
| private int cursor 0..size; the cursor | |
| mark | back to summary |
|---|---|
| private int mark 0..size; the mark | |
| MyInputStream | back to summary |
|---|---|
| public MyInputStream() | |
| available | back to summary |
|---|---|
| public int available() Overrides java. Doc from java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. Note that while some implementations of A subclass's implementation of this method may choose to throw an
| |
| mark | back to summary |
|---|---|
| public void mark(int reserve) Overrides java. Doc from java. Marks the current position in this input stream. A subsequent call to
the The The general contract of Marking a closed stream should not have any effect on the stream.
| |
| markSupported | back to summary |
|---|---|
| public boolean markSupported() Overrides java. Doc from java. Tests if this input stream supports the
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(byte[] arr, int offset, int length) Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |
| reset | back to summary |
|---|---|
| public void reset() Overrides java. Doc from java. Repositions this stream to the position at the time the
The general contract of
| |