Skip to content

Commit 387993e

Browse files
ctruedengab1one
authored andcommitted
DataHandle: fix up the endianness API
Now we have both isLittleEndian() and isBigEndian() accessors, and the setOrder(boolean) method is now setLittleEndian(boolean).
1 parent 12cb94f commit 387993e

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/main/java/org/scijava/io/DataHandle.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,32 @@ default boolean ensureWritable(final long count) throws IOException {
135135
*/
136136
void setOrder(ByteOrder order);
137137

138-
/** Gets the endianness of the stream. */
138+
/**
139+
* Returns true iff the stream's order is {@link ByteOrder#BIG_ENDIAN}.
140+
*
141+
* @see #getOrder()
142+
*/
143+
default boolean isBigEndian() {
144+
return getOrder() == ByteOrder.BIG_ENDIAN;
145+
}
146+
147+
/**
148+
* Returns true iff the stream's order is {@link ByteOrder#LITTLE_ENDIAN}.
149+
*
150+
* @see #getOrder()
151+
*/
139152
default boolean isLittleEndian() {
140153
return getOrder() == ByteOrder.LITTLE_ENDIAN;
141154
}
142155

143-
/** Sets the endianness of the stream. */
144-
default void setOrder(final boolean little) {
156+
/**
157+
* Sets the endianness of the stream.
158+
*
159+
* @param little If true, sets the order to {@link ByteOrder#LITTLE_ENDIAN};
160+
* otherwise, sets the order to {@link ByteOrder#BIG_ENDIAN}.
161+
* @see #setOrder(ByteOrder)
162+
*/
163+
default void setLittleEndian(final boolean little) {
145164
setOrder(little ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
146165
}
147166

0 commit comments

Comments
 (0)