public class ByteArray extends ReadOnlyByteArray
ReadOnlyByteArray to allow for elements to be written to the array
slice. This class works just like its parent; so you get relative indexing
and any changes to the original array will be visible in the corresponding
ByteArray object, and vice-versa, any invocation of the
set methods will be reflected into the original array.base, length, offset| Constructor and Description |
|---|
ByteArray(byte[] base,
int offset,
int length)
Creates a read-write slice of
base. |
| Modifier and Type | Method and Description |
|---|---|
void |
set(int index,
byte value)
Writes
value into the element at the index
position within this slice. |
void |
set(int index,
byte[] buf)
Copies the values in
buf into this slice, starting from
index. |
int |
set(int index,
int maxLength,
InputStream in)
Writes up to
maxLength bytes from the supplied stream into
this slice, starting from index. |
checkIndex, getpublic ByteArray(byte[] base,
int offset,
int length)
base. The
offset argument marks the start of the slice, at
base[offset]. The length argument defines
the length of the slice, the last element being
base[offset+length-1]. Obviously enough, these two
arguments must define an interval [offset, offset+length]
in [0, base.length].base - The original array.offset - The start of the slice.length - The length of the slice.public void set(int index,
byte value)
value into the element at the index
position within this slice.index - The index, within this slice, at which to write. Must be in
the [0, ReadOnlyByteArray.length)
interval.value - The value to write.public void set(int index,
byte[] buf)
buf into this slice, starting from
index. This method first checks to see whether
buf.length bytes can be written into this slice starting
from index. If the check fails an
ArrayIndexOutOfBoundsException is thrown and no data is copied at
all.index - The index, within this slice, from which to start writing.
Must be in the [0, ReadOnlyByteArray.length)
interval.buf - A buffer containing the values to write. Mustn't be
null and must fit into this slice. If the
length is 0, then this method does nothing.NullPointerException - If a null buffer is specified.public int set(int index,
int maxLength,
InputStream in)
throws IOException
maxLength bytes from the supplied stream into
this slice, starting from index. To be precise, this
method will attempt to write m bytes into this slice
(starting from the element at index), m
being the minimum of the following numbers: maxLength,
this.length - index
(that is, bytes from index to the end of the slice), and
the number of bytes to the end of the supplied stream.index - The index, within this slice, from which to start writing.
Must be in the
[0, ReadOnlyByteArray.length)
interval.maxLength - The maximum amount of bytes to write. If not positive, this
method does nothing and returns 0.in - The stream from which to read data. Mustn't be
null.-1 if the
end of the stream has been reached.IOException - If an I/O error occurred while reading data from the stream.NullPointerException - If the specified input stream is
null.
Version: 5.2.1-ice35-b15
Copyright © 2015 The University of Dundee & Open Microscopy Environment. All Rights Reserved.