|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectome.util.mem.ReadOnlyByteArray
ome.util.mem.ByteArray
public class ByteArray
A read-write slice of a given array. This class extends
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.
Field Summary |
---|
Fields inherited from class ome.util.mem.ReadOnlyByteArray |
---|
base, length, offset |
Constructor Summary | |
---|---|
ByteArray(byte[] base,
int offset,
int length)
Creates a read-write slice of base . |
Method Summary | |
---|---|
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 . |
Methods inherited from class ome.util.mem.ReadOnlyByteArray |
---|
checkIndex, get |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public 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.Method Detail |
---|
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
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Version: Beta4.2.1-r8614-Beta4.2-b41
Copyright © 2009 The University of Dundee. All Rights Reserved.