Class UnsignedBuffer
Object
UnsignedBuffer
- Direct Known Subclasses:
UnsignedBufferAsInt
,UnsignedIntBuffer
Base class for buffers that represent an unsigned-type in the signed-equivalent-type NIO
Buffer
.
This class exists as Java does not supported unsigned primitive types (apart from char), so it is necessary to explicitly convert an unsigned primitive type to a larger primitive type for arithmetic operations (e.g. unsigned bytes need to be converted to short or higher, unsigned shorts to int or higher, unsigned int to long or higher).
Subclasses must define a sensible Object.equals(java.lang.Object)
and Object.hashCode()
that takes
account the delegate buffer.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
final int
capacity()
The capacity of the buffer alaBuffer.capacity
.final void
clear()
Clears the buffer alaBuffer.clear()
.boolean
boolean
hasArray()
Whether the buffer has an array?int
hashCode()
final boolean
Whether there are elements between the current position and the limitBuffer.hasRemaining()
.boolean
isDirect()
Is this buffer direct or non-direct?final int
position()
The position of the buffer alaBuffer.position
.final Buffer
position
(int newPosition) Assigns a new position to the buffer.abstract void
putDouble
(double value) Puts a double at the current buffer position.abstract void
putDouble
(int index, double value) Puts a double at a particular buffer position.abstract void
putFloat
(float value) Puts a float at the current buffer position.abstract void
putFloat
(int index, float value) Puts a float at a particular buffer position.abstract void
putLong
(long value) Puts a long at the current buffer position.
-
Constructor Details
-
UnsignedBuffer
Creates a newUnsignedBuffer
instance.- Parameters:
delegate
- The delegate buffer
-
-
Method Details
-
putFloat
public abstract void putFloat(float value) Puts a float at the current buffer position.A conversion occurs from float to short.
- Parameters:
value
- the float.
-
putFloat
public abstract void putFloat(int index, float value) Puts a float at a particular buffer position.A conversion occurs from float to byte.
- Parameters:
index
- the buffer positionvalue
- the float.
-
putDouble
public abstract void putDouble(double value) Puts a double at the current buffer position.- Parameters:
value
- the double
-
putDouble
public abstract void putDouble(int index, double value) Puts a double at a particular buffer position.- Parameters:
index
- the buffer positionvalue
- the double
-
putLong
public abstract void putLong(long value) Puts a long at the current buffer position.- Parameters:
value
- the long.
-
hasRemaining
public final boolean hasRemaining()Whether there are elements between the current position and the limitBuffer.hasRemaining()
.- Returns:
- true iff elements exist
-
position
public final int position()The position of the buffer alaBuffer.position
.- Returns:
- the position
-
position
Assigns a new position to the buffer.This is meant in the sense of Java's NIO
Buffer
classes.- Parameters:
newPosition
- the index to assign as position.- Returns:
- the buffer.
-
capacity
public final int capacity()The capacity of the buffer alaBuffer.capacity
.- Returns:
- the capacity
-
clear
public final void clear()Clears the buffer alaBuffer.clear()
. -
isDirect
public boolean isDirect()Is this buffer direct or non-direct?This is meant in the sense of Java's NIO
Buffer
classes.- Returns:
- true iff the buffer is direct.
-
hasArray
public boolean hasArray()Whether the buffer has an array?This is meant in the sense of Java's NIO
Buffer
classes.- Returns:
- true if the buffer has an array
-
equals
-
canEqual
-
hashCode
public int hashCode()
-