Package org.opendaylight.raft.spi
Class ByteArray
java.lang.Object
org.opendaylight.raft.spi.ByteArray
- All Implemented Interfaces:
SizedStreamSource
,StreamSource
@NonNullByDefault
public abstract sealed class ByteArray
extends Object
implements SizedStreamSource
The moral equivalent of a
byte[]
, but perhaps allocated in chunks so as to be GC-friendly.-
Method Summary
Modifier and TypeMethodDescriptionabstract List
<byte[]> chunks()
Returns the list of chunks.abstract void
copyTo
(DataOutput output) Copy this array into specifiedDataOutput
.abstract void
copyTo
(OutputStream output) Copy this array into specifiedDataOutput
.static final ByteArray
empty()
Returns an emptyByteArray
.abstract int
Returns the size of this array.abstract InputStream
Open anInputStream
.static ByteArray
final long
size()
Returns the size of this data source, which is to say the number of bytes available for reading from the stream returned byStreamSource.openStream()
.final String
toString()
static final ByteArray
wrap
(byte[] bytes) Wrap abyte[]
in aByteArray
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opendaylight.raft.spi.SizedStreamSource
toSizedStreamSource
Methods inherited from interface org.opendaylight.raft.spi.StreamSource
openBufferedStream, openDataInput
-
Method Details
-
openStream
Description copied from interface:StreamSource
Open anInputStream
.- Specified by:
openStream
in interfaceStreamSource
- Returns:
- an InputStream
-
size
public final long size()Description copied from interface:SizedStreamSource
Returns the size of this data source, which is to say the number of bytes available for reading from the stream returned byStreamSource.openStream()
.- Specified by:
size
in interfaceSizedStreamSource
- Returns:
- the size of this data source
-
legacySize
public abstract int legacySize()Returns the size of this array.- Returns:
- the size of this array
-
copyTo
Copy this array into specifiedDataOutput
.- Parameters:
output
- the data output- Throws:
IOException
- if an I/O error occurs
-
copyTo
Copy this array into specifiedDataOutput
.- Parameters:
output
- the data output- Throws:
IOException
- if an I/O error occurs
-
chunks
Returns the list of chunks.- Returns:
- the list of chunks
-
empty
Returns an emptyByteArray
.- Returns:
- an empty
ByteArray
-
wrap
Wrap abyte[]
in aByteArray
.- Parameters:
bytes
- bytes to wrap- Returns:
- a
ByteArray
-
readFrom
- Parameters:
in
- the inputsize
- size of inputchunkSize
- target chunk size- Returns:
- a
ByteArray
- Throws:
IOException
- if an I/O error occurs
-
toString
-