public abstract class AbstractByteSource extends java.lang.Object implements ByteSource
ByteSource
. This class
implements some common methods that most classes will not want to override.
In particular, it maps all get methods without an offset to their counterpart
with an offset, so that the number of methods to implement is reduced.ByteSource.AtomicGetOperation<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 |
AbstractByteSource()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
byte |
getByte()
Reads a single byte and advances the current position.
|
byte[] |
getByteArray(int length)
Reads the specified number of bytes and advances the current position.
|
double |
getDouble()
Reads a single double and advances the current position.
|
AbstractByteSource |
getDoubleArray(double[] destination,
int offset,
int length)
Reads the specified number of double values into the supplied array and
advances the current position.
|
double[] |
getDoubleArray(int length)
Reads the specified number of doubles and advances the current position.
|
float |
getFloat()
Reads a single float and advances the current position.
|
AbstractByteSource |
getFloatArray(float[] destination,
int offset,
int length)
Reads the specified number of float values into the supplied array and
advances the current position.
|
float[] |
getFloatArray(int length)
Reads the specified number of floats and advances the current position.
|
int |
getInt()
Reads a single int and advances the current position.
|
int[] |
getIntArray(int length)
Reads the specified number of ints and advances the current position.
|
AbstractByteSource |
getIntArray(int[] destination,
int offset,
int length)
Reads the specified number of int values into the supplied array and
advances the current position.
|
long |
getLong()
Reads a single long and advances the current position.
|
long[] |
getLongArray(int length)
Reads the specified number of longs and advances the current position.
|
AbstractByteSource |
getLongArray(long[] destination,
int offset,
int length)
Reads the specified number of long values into the supplied array and
advances the current position.
|
short |
getShort()
Reads a single short and advances the current position.
|
short[] |
getShortArray(int length)
Reads the specified number of shorts and advances the current position.
|
AbstractByteSource |
getShortArray(short[] destination,
int offset,
int length)
Reads the specified number of short values into the supplied array and
advances the current position.
|
java.lang.String |
toString()
Returns a string representation of this byte source.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
atomicGet, getByteArray, remaining, skip
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 AbstractByteSource()
public byte getByte()
ByteSource
getByte
in interface ByteSource
public byte[] getByteArray(int length)
ByteSource
this.getByteArray(new byte[length], 0, length)
.getByteArray
in interface ByteSource
length
- number of bytes to be read.public double getDouble()
ByteSource
getDouble
in interface ByteSource
public double[] getDoubleArray(int length)
ByteSource
this.getDoubleArray(new double[length], 0, length)
.getDoubleArray
in interface ByteSource
length
- number of doubles to be read.public AbstractByteSource getDoubleArray(double[] destination, int offset, int length)
ByteSource
getDoubleArray
in interface ByteSource
destination
- array into which the read values are copied. This array's
length must be at least
length + destinationOffset
.offset
- offset into the destination array. The destination array is
filled starting at this position.length
- number of values to be read.public float getFloat()
ByteSource
getFloat
in interface ByteSource
public float[] getFloatArray(int length)
ByteSource
this.getFloatArray(new float[length], 0, length)
.getFloatArray
in interface ByteSource
length
- number of floats to be read.public AbstractByteSource getFloatArray(float[] destination, int offset, int length)
ByteSource
getFloatArray
in interface ByteSource
destination
- array into which the read values are copied. This array's
length must be at least
length + destinationOffset
.offset
- offset into the destination array. The destination array is
filled starting at this position.length
- number of values to be read.public int getInt()
ByteSource
getInt
in interface ByteSource
public int[] getIntArray(int length)
ByteSource
this.getIntArray(new int[length], 0, length)
.getIntArray
in interface ByteSource
length
- number of ints to be read.public AbstractByteSource getIntArray(int[] destination, int offset, int length)
ByteSource
getIntArray
in interface ByteSource
destination
- array into which the read values are copied. This array's
length must be at least
length + destinationOffset
.offset
- offset into the destination array. The destination array is
filled starting at this position.length
- number of values to be read.public long getLong()
ByteSource
getLong
in interface ByteSource
public long[] getLongArray(int length)
ByteSource
this.getLongArray(new long[length], 0, length)
.getLongArray
in interface ByteSource
length
- number of longs to be read.public AbstractByteSource getLongArray(long[] destination, int offset, int length)
ByteSource
getLongArray
in interface ByteSource
destination
- array into which the read values are copied. This array's
length must be at least
length + destinationOffset
.offset
- offset into the destination array. The destination array is
filled starting at this position.length
- number of values to be read.public short getShort()
ByteSource
getShort
in interface ByteSource
public short[] getShortArray(int length)
ByteSource
this.getShortArray(new short[length], 0, length)
.getShortArray
in interface ByteSource
length
- number of shorts to be read.public AbstractByteSource getShortArray(short[] destination, int offset, int length)
ByteSource
getShortArray
in interface ByteSource
destination
- array into which the read values are copied. This array's
length must be at least
length + destinationOffset
.offset
- offset into the destination array. The destination array is
filled starting at this position.length
- number of values to be read.public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2014–2017 aquenos GmbH. All rights reserved.