Skip to content

Commit d6a4271

Browse files
committed
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 90f2d41 commit d6a4271

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

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

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

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

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

0 commit comments

Comments
 (0)