This is the de-facto implementation of the interface ByteRegion. Users who wish to create an instance of ByteRegion should use the static factory methods in this class.
Clients who are dealing with ByteRegion instances may check for them if they're an instance of ByteArrayRegion, and use the backing byte array directly to improve reading and writing performance. This instance of checking works through RMI connections.
The array backed by instances of this class is defined by an offset. The actual byte region starts at the mentioned offset index, and clients should only access the region defined by it and the length.
Methods of this class accept the index parameter relative to the aforementioned offset, i.e. index 0 is the same as accessing the byte at the starting offset.
This class can't be subclassed by clients, and they should use the static factory methods to retrieve an instance.
public static final ByteArrayRegion | Singleton instance for an empty ByteArrayRegion. |
public static ByteArrayRegion | allocate( Allocates a new byte array with the given length and returns it as a ByteArrayRegion. |
public abstract byte[] | Gets an array that contains the full range of this region. |
public abstract byte[] | getArray() Gets the underlying array for this instance. |
public abstract int | Gets the offset of the range for this instance. |
public boolean | isEmpty() Checks if this region contains any bytes. |
public void | put( Puts an array of bytes into this region starting at the given index. |
public abstract void | put( Puts an array range of bytes into this region starting at the given index. |
public boolean | regionEquals( Checks if the byte contents defined by this region equals to the contents of the argument region. |
public String | toString() Returns a string representation of the object. |
public String | Returns a string representation of this byte region by decoding its contents using the given charset. |
public static ByteArrayRegion | wrap( Gets a byte array region that wraps the argument array. |
public static ByteArrayRegion | wrap( Gets a byte array region that wraps the argument range of the specified array. |
public abstract long | writeTo( Writes the contents of this byte array region to the argument data output. |
public abstract long | writeTo( Writes the contents of this byte array region to the argument output stream. |
From: Object |
From: Externalizable |
From: ByteRegion |
This is the same as calling:
ByteArrayRegion.wrap(new byte[length]);Callers shouldn't rely on the identity of the returned byte array. This method may optimize the allocation for a 0 length byte array, and return a shared object.
This method is similar to ByteRegion.copy(), but if the range is defined to contain the whole underlying array, then no copies are made.
The modifications made to the returned array may or may not modify the actually represented byte region.
The returned array will have a length of ByteRegion.getLength().
The array should only be accessed in the range defined for this instance.
true
if the region is empty.The index is 0 based, where the index 0 means that the first byte will be written at the offset in the underlying array.
The full contents of the argument array will be copied into the underlying array for this byte array region.
This method is the same as calling:
put(index, bytes, 0, bytes.length);
null
.The index is 0 based, where the index 0 means that the first byte will be written at the offset in the underlying array.
The contents of the argument array in the given range will be copied into the underlying array for this byte array region.
null
.true
if the bytes are the same in the byte regions defined by this
and the
argument.toString
method returns a string that
"textually represents" this object. The result should be a concise but informative representation that is easy
for a person to read. It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of
which the object is an instance, the at-sign character `@
', and the unsigned hexadecimal representation
of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
null
.The returned region will contain the whole array argument.
If the array is empty, the method will return EMPTY, and not a new instance.
null
.If the array is empty, the method will return EMPTY, and not a new instance.
null
.