Package com.aurumsmods.littlebigio
Interface ByteOrdered
- All Known Implementing Classes:
BinaryInputStream
,BinaryOutputStream
public interface ByteOrdered
An interface for byte order-dependent components, such as IO streams. The
ByteOrder
value can be retrieved or set to another value. Every class
should consist of a single ByteOrder
attribute which can be accessed
by getOrder()
and setOrder(ByteOrder)
.
It is not allowed that the attribute be null
. The developer has to
ensure that getOrder()
never returns null
as well as
setOrder(ByteOrder)
never sets the attribute to null
.
The contract does not prescribe how to work with multithreaded applications.
-
Method Summary
Modifier and TypeMethodDescriptiongetOrder()
Returns theByteOrder
.default boolean
Returnstrue
if the byte order isByteOrder.BIG_ENDIAN
.default boolean
Returnstrue
if the byte order isByteOrder.LITTLE_ENDIAN
.default boolean
Returnstrue
if the byte order equals the machine's native order.void
Sets theByteOrder
.default void
Swaps theByteOrder
.
-
Method Details
-
getOrder
ByteOrder getOrder()Returns theByteOrder
. This should always return a proper instance,null
is not allowed.- Returns:
- the
ByteOrder
.
-
setOrder
- Parameters:
byteOrder
- theByteOrder
.- Throws:
NullPointerException
- ifbyteOrder
isnull
.
-
isBigEndian
default boolean isBigEndian()- Returns:
true
if byte order isByteOrder.BIG_ENDIAN
, otherwisefalse
.
-
isLittleEndian
default boolean isLittleEndian()- Returns:
true
if byte order isByteOrder.LITTLE_ENDIAN
, otherwisefalse
.
-
isNativeOrder
default boolean isNativeOrder()Returnstrue
if the byte order equals the machine's native order. Otherwise, returnsfalse
.- Returns:
true
if byte order equals the machine's native order.- See Also:
-
swapOrder
default void swapOrder()Swaps theByteOrder
. If it's currently set toByteOrder.BIG_ENDIAN
, it will be changed toByteOrder.LITTLE_ENDIAN
. However, if it's currently set toByteOrder.LITTLE_ENDIAN
, it will be changed toByteOrder.BIG_ENDIAN
.
-