public final class UtilConversion extends Object
This class is Thread-Safe.
Modifier and Type | Method and Description |
---|---|
static int |
boolToInt(boolean value)
Convert boolean to integer representation.
|
static int |
byteArrayToInt(byte[] bytes)
Convert a byte array to an integer.
|
static short |
byteArrayToShort(byte[] bytes)
Convert a byte array to an integer.
|
static int |
fromBinary(boolean[] binary)
Convert binary array to number representation.
|
static byte |
fromUnsignedByte(short value)
Return the java byte value [-128|127] from an unsigned byte [0|255].
|
static short |
fromUnsignedShort(int value)
Return the java short value [-32768|32767] from an unsigned short [0|65535].
|
static byte[] |
intToByteArray(int value)
Convert an integer to an array of byte.
|
static boolean[] |
invert(boolean[] binary)
Invert binary array (apply a negation to each value).
|
static int |
mask(int value)
Return the masked value by 0xFF.
|
static byte[] |
shortToByteArray(short value)
Convert a short to an array of byte.
|
static boolean[] |
toBinary(int number,
int length)
Convert number to binary array representation.
|
static String |
toTitleCase(String string)
Convert a string to title case.
|
static String |
toTitleCaseWord(String string)
Convert a string to a pure title case for each word, replacing special characters by space.
|
static short |
toUnsignedByte(byte value)
Return the unsigned byte value [0|255] from the java byte value [-128|127].
|
static int |
toUnsignedShort(short value)
Return the unsigned short value [0|65535] from the java short value [-32768|32767].
|
public static byte[] intToByteArray(int value)
value
- The integer value.public static int byteArrayToInt(byte[] bytes)
bytes
- The byte array.public static byte[] shortToByteArray(short value)
value
- The short value.public static short byteArrayToShort(byte[] bytes)
bytes
- The byte array.public static byte fromUnsignedByte(short value)
value
- The unsigned byte value [0|255].public static short toUnsignedByte(byte value)
value
- The java byte value [-128|127].public static short fromUnsignedShort(int value)
value
- The unsigned short value [0|65535].public static int toUnsignedShort(short value)
value
- The java short value [-32768|32767].public static int mask(int value)
value
- The input value.public static int boolToInt(boolean value)
value
- The boolean value.1
if true
, 0
if false
.public static boolean[] toBinary(int number, int length)
number
- The number to convert.length
- The binary length.public static int fromBinary(boolean[] binary)
binary
- The binary to convert.public static boolean[] invert(boolean[] binary)
binary
- The binary array.public static String toTitleCase(String string)
string
- The string to convert.Copyright © 2016 Byron 3D Games Studio. All rights reserved.