2525 *
2626 * @since 2.6
2727 */
28- public final class ByteOrderUtils {
29-
30- private static final Locale ComparisonLocale = Locale .ROOT ;
31-
32- /**
33- * Big endian.
34- */
35- public static final String BIG_ENDIAN = "Big" ;
36-
37- /**
38- * Little endian.
39- */
40- public static final String LITTLE_ENDIAN = "Little" ;
28+ public final class ByteOrderParser {
4129
4230 /**
4331 * ByteOrderUtils is a static utility class, so prevent construction with a private constructor.
4432 */
45- private ByteOrderUtils () {
33+ private ByteOrderParser () {
4634 }
4735
4836 /**
4937 * Parses the String argument as a {@link ByteOrder}, ignoring case.
5038 * <p>
51- * Returns {@code ByteOrder.LITTLE_ENDIAN} if the given value is {@code "little"} or {@code " LITTLE_ENDIAN"}.
39+ * Returns {@code ByteOrder.LITTLE_ENDIAN} if the given value is {@code "LITTLE_ENDIAN"}.
5240 * </p>
5341 * <p>
54- * Returns {@code ByteOrder.BIG_ENDIAN} if the given value is {@code "big"} or {@code " BIG_ENDIAN"}.
42+ * Returns {@code ByteOrder.BIG_ENDIAN} if the given value is {@code "BIG_ENDIAN"}.
5543 * </p>
5644 * Examples:
5745 * <ul>
58- * <li>{@code ByteOrderUtils .parseByteOrder("little ")} returns {@code ByteOrder.LITTLE_ENDIAN}</li>
59- * <li>{@code ByteOrderUtils .parseByteOrder("big ")} returns {@code ByteOrder.BIG_ENDIAN}</li>
46+ * <li>{@code ByteOrderParser .parseByteOrder("LITTLE_ENDIAN ")} returns {@code ByteOrder.LITTLE_ENDIAN}</li>
47+ * <li>{@code ByteOrderParser .parseByteOrder("BIG_ENDIAN ")} returns {@code ByteOrder.BIG_ENDIAN}</li>
6048 * </ul>
6149 *
6250 * @param value
@@ -66,17 +54,14 @@ private ByteOrderUtils() {
6654 * if the {@code String} containing the ByteOrder representation to be parsed is unknown.
6755 */
6856 public static ByteOrder parseByteOrder (final String value ) {
69- final String valueUp = value .toUpperCase (ComparisonLocale );
70- final String bigEndianUp = BIG_ENDIAN .toUpperCase (ComparisonLocale );
71- final String littleEndianUp = LITTLE_ENDIAN .toUpperCase (ComparisonLocale );
72- if (bigEndianUp .equals (valueUp ) || ByteOrder .BIG_ENDIAN .toString ().equals (valueUp )) {
57+ if (ByteOrder .BIG_ENDIAN .toString ().equals (value )) {
7358 return ByteOrder .BIG_ENDIAN ;
7459 }
75- if (littleEndianUp . equals ( valueUp ) || ByteOrder .LITTLE_ENDIAN .toString ().equals (valueUp )) {
60+ if (ByteOrder .LITTLE_ENDIAN .toString ().equals (value )) {
7661 return ByteOrder .LITTLE_ENDIAN ;
7762 }
78- throw new IllegalArgumentException ("Unsupported byte order setting: " + value + ", expeced one of " + ByteOrder .LITTLE_ENDIAN + ", " +
79- LITTLE_ENDIAN + ", " + ByteOrder .BIG_ENDIAN + ", " + bigEndianUp );
63+ throw new IllegalArgumentException ("Unsupported byte order setting: " + value + ", expeced one of " + ByteOrder .LITTLE_ENDIAN +
64+ ", " + ByteOrder .BIG_ENDIAN );
8065 }
8166
8267}
0 commit comments