public abstract class AbstractByteSink extends Object implements ByteSink
Abstract base class for ByteSink
implementations. This base class
implements most of the methods declared in the ByteSink
interface.
However, the typed put operations in this class incur an extra copy operation
in order to convert the raw data-type to bytes.
If possible, implementations should override the typed put operations with a more efficient implementation that can write the data type directly. Usually, it is sufficient to override the operations that take an array as well as an offset and length, because those methods a called by the convenience methods that take a single value or an array without additional parameters. However, derived classes are also free to override the other methods, if they can provide a more efficient implementation for them.
ByteSink.AtomicPutOperation<T>
Modifier and Type | Field and Description |
---|---|
protected static int |
SIZE_OF_BYTE
Size of a byte in bytes.
|
protected static int |
SIZE_OF_DOUBLE
Size of a double in bytes.
|
protected static int |
SIZE_OF_FLOAT
Size of a float in bytes.
|
protected static int |
SIZE_OF_INT
Size of an int in bytes.
|
protected static int |
SIZE_OF_LONG
Size of a long in bytes.
|
protected static int |
SIZE_OF_SHORT
Size of a short in bytes.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractByteSink()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
ByteSink |
putByte(byte b)
Writes a single byte to this byte sink.
|
ByteSink |
putByteArray(byte[] source)
Writes a complete array of bytes to this byte sink.
|
ByteSink |
putDouble(double value)
Writes a single double value to this byte sink.
|
ByteSink |
putDoubleArray(double[] source)
Writes a complete array of double values to this byte sink.
|
ByteSink |
putDoubleArray(double[] source,
int offset,
int length)
Writes a slice of an array of double values to this byte sink.
|
ByteSink |
putFloat(float value)
Writes a single float value to this byte sink.
|
ByteSink |
putFloatArray(float[] source)
Writes a complete array of float values to this byte sink.
|
ByteSink |
putFloatArray(float[] source,
int offset,
int length)
Writes a slice of an array of float values to this byte sink.
|
ByteSink |
putInt(int value)
Writes a single int value to this byte sink.
|
ByteSink |
putIntArray(int[] source)
Writes a complete array of int values to this byte sink.
|
ByteSink |
putIntArray(int[] source,
int offset,
int length)
Writes a slice of an array of int values to this byte sink.
|
ByteSink |
putLong(long value)
Writes a single long value to this byte sink.
|
ByteSink |
putLongArray(long[] source)
Writes a complete array of long values to this byte sink.
|
ByteSink |
putLongArray(long[] source,
int offset,
int length)
Writes a slice of an array of long values to this byte sink.
|
ByteSink |
putShort(short value)
Writes a single short value to this byte sink.
|
ByteSink |
putShortArray(short[] source)
Writes a complete array of short values to this byte sink.
|
ByteSink |
putShortArray(short[] source,
int offset,
int length)
Writes a slice of an array of short values to this byte sink.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
atomicPut, putByteArray
protected static final int SIZE_OF_BYTE
protected static final int SIZE_OF_DOUBLE
protected static final int SIZE_OF_FLOAT
protected static final int SIZE_OF_INT
protected static final int SIZE_OF_LONG
protected static final int SIZE_OF_SHORT
protected AbstractByteSink()
public ByteSink putByte(byte b)
ByteSink
public ByteSink putByteArray(byte[] source)
ByteSink
putByteArray
in interface ByteSink
source
- array of bytes that should be completely written to this byte
sink.public ByteSink putDouble(double value)
ByteSink
public ByteSink putDoubleArray(double[] source)
ByteSink
putDoubleArray
in interface ByteSink
source
- array of double values that should be completely written to
this byte sink.public ByteSink putDoubleArray(double[] source, int offset, int length)
ByteSink
putDoubleArray
in interface ByteSink
source
- array of double values that should be partially written to
this byte sink.offset
- offset into source
. Data will be read from the
array starting at this index.length
- number of values to be written.public ByteSink putFloat(float value)
ByteSink
public ByteSink putFloatArray(float[] source)
ByteSink
putFloatArray
in interface ByteSink
source
- array of float values that should be completely written to
this byte sink.public ByteSink putFloatArray(float[] source, int offset, int length)
ByteSink
putFloatArray
in interface ByteSink
source
- array of float values that should be partially written to this
byte sink.offset
- offset into source
. Data will be read from the
array starting at this index.length
- number of values to be written.public ByteSink putInt(int value)
ByteSink
public ByteSink putIntArray(int[] source)
ByteSink
putIntArray
in interface ByteSink
source
- array of int values that should be completely written to this
byte sink.public ByteSink putIntArray(int[] source, int offset, int length)
ByteSink
putIntArray
in interface ByteSink
source
- array of int values that should be partially written to this
byte sink.offset
- offset into source
. Data will be read from the
array starting at this index.length
- number of values to be written.public ByteSink putShort(short value)
ByteSink
public ByteSink putShortArray(short[] source)
ByteSink
putShortArray
in interface ByteSink
source
- array of short values that should be completely written to
this byte sink.public ByteSink putShortArray(short[] source, int offset, int length)
ByteSink
putShortArray
in interface ByteSink
source
- array of short values that should be partially written to this
byte sink.offset
- offset into source
. Data will be read from the
array starting at this index.length
- number of values to be written.public ByteSink putLong(long value)
ByteSink
public ByteSink putLongArray(long[] source)
ByteSink
putLongArray
in interface ByteSink
source
- array of long values that should be completely written to this
byte sink.public ByteSink putLongArray(long[] source, int offset, int length)
ByteSink
putLongArray
in interface ByteSink
source
- array of long values that should be partially written to this
byte sink.offset
- offset into source
. Data will be read from the
array starting at this index.length
- number of values to be written.Copyright © 2014–2017 aquenos GmbH. All rights reserved.