Class BitTools

java.lang.Object
tools.BitTools

public class BitTools extends Object
Provides static methods for working with raw byte sequences.
Since:
Revision 206
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final int
    Turns a double-precision floating point integer into an integer.
    static final String
    getMapleString(byte[] array, int index)
    Reads a maplestory-convention string from array at index
    static final int
    getShort(byte[] array, int index)
    Reads a short from array at index
    static final String
    getString(byte[] array, int index, int length)
    Reads a string from array at index length in length.
    static final byte[]
    multiplyBytes(byte[] in, int count, int mul)
    Repeats count bytes of in mul times.
    static final byte
    rollLeft(byte in, int count)
    Rotates the bits of in count places to the left.
    static final byte
    rollRight(byte in, int count)
    Rotates the bits of in count places to the right.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BitTools

      public BitTools()
  • Method Details

    • getShort

      public static final int getShort(byte[] array, int index)
      Reads a short from array at index
      Parameters:
      array - The byte array to read the short integer from.
      index - Where reading begins.
      Returns:
      The short integer value.
    • getString

      public static final String getString(byte[] array, int index, int length)
      Reads a string from array at index length in 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

      public static final String getMapleString(byte[] array, int index)
      Reads a maplestory-convention string from array at index
      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 of in count places to the left.
      Parameters:
      in - The byte to rotate the bits
      count - Number of times to rotate.
      Returns:
      The rotated byte.
    • rollRight

      public static final byte rollRight(byte in, int count)
      Rotates the bits of in count places to the right.
      Parameters:
      in - The byte to rotate the bits
      count - Number of times to rotate.
      Returns:
      The rotated byte.
    • multiplyBytes

      public static final byte[] multiplyBytes(byte[] in, int count, int mul)
      Repeats count bytes of in mul times.
      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.