Package com.streambase.sb
Class DirectByteArrayView
java.lang.Object
com.streambase.sb.ByteArrayView
com.streambase.sb.DirectByteArrayView
- All Implemented Interfaces:
com.streambase.sb.internal.CloneableData
,Serializable
,Cloneable
,Comparable<ByteArrayView>
Direct byte array view into data
-
Constructor Summary
ConstructorDescriptionDirectByteArrayView
(byte[] data) ConstructorDirectByteArrayView
(byte[] data, int off, int len) Constructor -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
array()
Returns a reference to the backing array for this view.copy()
Create a new ByteArrayView which wraps a new byte[] containing a copy of this view's data NB: this method copies the underlying datacopy
(int off, int len) Create a new ByteArrayView which wraps a new byte[] containing a copy of this view's data NB: this method copies the underlying databyte[]
Create a new byte[] containing a copy of this view's data.byte[]
copyBytes
(int off, int len) Create a new byte[] containing a copy of this view's data within the provided window.int
length()
return the length of this view NB: no data is copied when doing thisint
offset()
return the offset into the backing array of this view NB: no data is copied when doing thisslice
(int off, int len) Create a new ByteArrayView which wraps a portion of this one NB: no data is copied when doing thisview()
Create a new ByteBuffer which wraps all of this one NB: no data is copied when doing thisview
(int off, int len) Create a new ByteBuffer which wraps a portion of this one NB: no data is copied when doing thisMethods inherited from class com.streambase.sb.ByteArrayView
asString, clone, compareTo, equals, get, hashCode, makeCopiedView, makeCopiedView, makeView, makeView, makeView, toString
-
Constructor Details
-
DirectByteArrayView
public DirectByteArrayView(byte[] data) Constructor- Parameters:
data
- array data
-
DirectByteArrayView
public DirectByteArrayView(byte[] data, int off, int len) Constructor- Parameters:
data
- array dataoff
- offset into datalen
- length of data
-
-
Method Details
-
slice
Description copied from class:ByteArrayView
Create a new ByteArrayView which wraps a portion of this one NB: no data is copied when doing this- Specified by:
slice
in classByteArrayView
- Parameters:
off
- the initial offset of the window (relative to the current window)len
- the length of the window- Returns:
- the new ByteArrayView
-
view
Description copied from class:ByteArrayView
Create a new ByteBuffer which wraps a portion of this one NB: no data is copied when doing this- Specified by:
view
in classByteArrayView
- Parameters:
off
- the initial offset of the window (relative to the current window)len
- the length of the window- Returns:
- a ByteBuffer whose arrayOffset() and limit() are the offset and length provided
-
view
Description copied from class:ByteArrayView
Create a new ByteBuffer which wraps all of this one NB: no data is copied when doing this- Specified by:
view
in classByteArrayView
- Returns:
- a ByteBuffer whose arrayOffset() and limit() are the offset() and length() of this view
-
array
public byte[] array()Description copied from class:ByteArrayView
Returns a reference to the backing array for this view. Note that the view might only be of a part of the returned array: this means you should only access the array between offsetsByteArrayView.offset()
and offset() +ByteArrayView.length()
. NB: no data is copied when doing this- Specified by:
array
in classByteArrayView
- Returns:
- the backing array
-
offset
public int offset()Description copied from class:ByteArrayView
return the offset into the backing array of this view NB: no data is copied when doing this- Specified by:
offset
in classByteArrayView
- Returns:
- the offset in bytes
-
length
public int length()Description copied from class:ByteArrayView
return the length of this view NB: no data is copied when doing this- Specified by:
length
in classByteArrayView
- Returns:
- the length in bytes
-
copy
Description copied from class:ByteArrayView
Create a new ByteArrayView which wraps a new byte[] containing a copy of this view's data NB: this method copies the underlying data- Specified by:
copy
in classByteArrayView
- Parameters:
off
- the initial offset of the window (relative to the current window)len
- the length of the window- Returns:
- the new ByteArrayView
- See Also:
-
copy
Description copied from class:ByteArrayView
Create a new ByteArrayView which wraps a new byte[] containing a copy of this view's data NB: this method copies the underlying data- Specified by:
copy
in classByteArrayView
- Returns:
- the new ByteArrayView
- See Also:
-
copyBytes
public byte[] copyBytes(int off, int len) Description copied from class:ByteArrayView
Create a new byte[] containing a copy of this view's data within the provided window. The returned array may be indexed from 0, unlikeByteArrayView.array()
. NB: this method copies the underlying data- Specified by:
copyBytes
in classByteArrayView
- Parameters:
off
- the initial offset of the window (relative to the current window)len
- the length of the window- Returns:
- the new byte[]
-
copyBytes
public byte[] copyBytes()Description copied from class:ByteArrayView
Create a new byte[] containing a copy of this view's data. The returned array may be indexed from 0, unlikeByteArrayView.array()
. NB: this method copies the underlying data- Specified by:
copyBytes
in classByteArrayView
- Returns:
- a new byte[] containing a copy of this view's data
-