Module hash4j

Class ByteArrayUtil

java.lang.Object
com.dynatrace.hash4j.internal.ByteArrayUtil

public final class ByteArrayUtil extends Object
Utility class for byte arrays.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    copyCharsToByteArray(CharSequence charSequence, int offetCharSequence, byte[] byteArray, int offsetByteArray, int numChars)
    Copies a given number of characters from a CharSequence into a byte array.
    static char
    getChar(byte[] b, int off)
    Reads a char from a byte array with given offset.
    static int
    getInt(byte[] b, int off)
    Reads an int value from a byte array with given offset.
    static int
    getInt(CharSequence charSequence, int off)
    Reads an int value from a CharSequence with given offset.
    static long
    getLong(byte[] b, int off)
    Reads a long value from a byte array with given offset.
    static long
    getLong(CharSequence charSequence, int off)
    Reads a long value from a CharSequence with given offset.
    static short
    getShort(byte[] b, int off)
    Reads a short value from a byte array with given offset.
    static void
    setChar(byte[] b, int off, char v)
    Writes a char to a byte array with given offset.
    static void
    setInt(byte[] b, int off, int v)
    Writes an int value to a byte array with given offset.
    static void
    setLong(byte[] b, int off, long v)
    Writes a long value to a byte array with given offset.
    static void
    setShort(byte[] b, int off, short v)
    Writes a short value to a byte array with given offset.

    Methods inherited from class java.lang.Object

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

    • getChar

      public static char getChar(byte[] b, int off)
      Reads a char from a byte array with given offset.
      Parameters:
      b - a byte array
      off - an offset
      Returns:
      the read character
    • getShort

      public static short getShort(byte[] b, int off)
      Reads a short value from a byte array with given offset.
      Parameters:
      b - a byte array
      off - an offset
      Returns:
      the read value
    • getInt

      public static int getInt(byte[] b, int off)
      Reads an int value from a byte array with given offset.
      Parameters:
      b - a byte array
      off - an offset
      Returns:
      the read value
    • getLong

      public static long getLong(byte[] b, int off)
      Reads a long value from a byte array with given offset.
      Parameters:
      b - a byte array
      off - an offset
      Returns:
      the read value
    • setLong

      public static void setLong(byte[] b, int off, long v)
      Writes a long value to a byte array with given offset.
      Parameters:
      b - a byte array
      off - an offset
      v - a value
    • setInt

      public static void setInt(byte[] b, int off, int v)
      Writes an int value to a byte array with given offset.
      Parameters:
      b - a byte array
      off - an offset
      v - a value
    • setShort

      public static void setShort(byte[] b, int off, short v)
      Writes a short value to a byte array with given offset.
      Parameters:
      b - a byte array
      off - an offset
      v - a value
    • getLong

      public static long getLong(CharSequence charSequence, int off)
      Reads a long value from a CharSequence with given offset.
      Parameters:
      charSequence - a char sequence
      off - an offset
      Returns:
      the value
    • getInt

      public static int getInt(CharSequence charSequence, int off)
      Reads an int value from a CharSequence with given offset.
      Parameters:
      charSequence - a char sequence
      off - an offset
      Returns:
      the value
    • setChar

      public static void setChar(byte[] b, int off, char v)
      Writes a char to a byte array with given offset.
      Parameters:
      b - a byte array
      off - an offset
      v - a character
    • copyCharsToByteArray

      public static void copyCharsToByteArray(CharSequence charSequence, int offetCharSequence, byte[] byteArray, int offsetByteArray, int numChars)
      Copies a given number of characters from a CharSequence into a byte array.
      Parameters:
      charSequence - a char sequence
      offetCharSequence - an offset for the char sequence
      byteArray - a byte array
      offsetByteArray - an offset for the byte array
      numChars - the number of characters to copy