Class BitTools
java.lang.Object
tools.BitTools
Provides static methods for working with raw byte sequences.
- Since:
- Revision 206
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final intdoubleToShortBits(double d) Turns a double-precision floating point integer into an integer.static final StringgetMapleString(byte[] array, int index) Reads a maplestory-convention string fromarrayatindexstatic final intgetShort(byte[] array, int index) Reads a short fromarrayatindexstatic final StringgetString(byte[] array, int index, int length) Reads a string fromarrayatindexlengthin length.static final byte[]multiplyBytes(byte[] in, int count, int mul) Repeatscountbytes ofinmultimes.static final byterollLeft(byte in, int count) Rotates the bits ofincountplaces to the left.static final byterollRight(byte in, int count) Rotates the bits ofincountplaces to the right.
-
Constructor Details
-
BitTools
public BitTools()
-
-
Method Details
-
getShort
public static final int getShort(byte[] array, int index) Reads a short fromarrayatindex- Parameters:
array- The byte array to read the short integer from.index- Where reading begins.- Returns:
- The short integer value.
-
getString
Reads a string fromarrayatindexlengthin length.- Parameters:
array- The array to read the string from.index- Where reading begins.length- The number of bytes to read.- Returns:
- The string read.
-
getMapleString
Reads a maplestory-convention string fromarrayatindex- Parameters:
array- The byte array to read from.index- Where reading begins.- Returns:
- The string read.
-
rollLeft
public static final byte rollLeft(byte in, int count) Rotates the bits ofincountplaces to the left.- Parameters:
in- The byte to rotate the bitscount- Number of times to rotate.- Returns:
- The rotated byte.
-
rollRight
public static final byte rollRight(byte in, int count) Rotates the bits ofincountplaces to the right.- Parameters:
in- The byte to rotate the bitscount- Number of times to rotate.- Returns:
- The rotated byte.
-
multiplyBytes
public static final byte[] multiplyBytes(byte[] in, int count, int mul) Repeatscountbytes ofinmultimes.- Parameters:
in- The array of bytes containing the bytes to multiply.count- The number of bytes to repeat.mul- The number of times to repeat.- Returns:
- The repeated bytes.
-
doubleToShortBits
public static final int doubleToShortBits(double d) Turns a double-precision floating point integer into an integer.- Parameters:
d- The double to transform.- Returns:
- The converted integer.
-