Class HexUtils


  • public final class HexUtils
    extends java.lang.Object
    Utilities for hex strings.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String hexBytesOfLong​(long v)
      Builds an hex String that represents the provided long value.
      static long longOfHexBytes​(java.lang.String str, int offset)
      Retrieves the long value represented by the provided hex String.
      static <T extends java.lang.CharSequence>
      T
      validateHexBytes​(T str)
      Checks that the provided CharSequence is a valid hex CharSequence, throwing an IllegalArgumentException if it is not.
      • Methods inherited from class java.lang.Object

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

      • validateHexBytes

        public static <T extends java.lang.CharSequence> T validateHexBytes​(T str)
        Checks that the provided CharSequence is a valid hex CharSequence, throwing an IllegalArgumentException if it is not.
        Type Parameters:
        T - The type of CharSequence to validate.
        Parameters:
        str - the CharSequence to check.
        Returns:
        the provided CharSequence unchanged.
      • longOfHexBytes

        public static long longOfHexBytes​(java.lang.String str,
                                          int offset)
        Retrieves the long value represented by the provided hex String. Throws StringIndexOutOfBoundsException if offset is invalid.
        Parameters:
        str - an hex String.
        offset - The index to start within str to start the conversion.
        Returns:
        the long value.
      • hexBytesOfLong

        public static java.lang.String hexBytesOfLong​(long v)
        Builds an hex String that represents the provided long value.
        Parameters:
        v - the long value.
        Returns:
        an hex String.