Class StringHex

java.lang.Object
com.helger.base.string.StringHex

@Immutable public class StringHex extends Object
  • Method Details

    • getHexChar

      public static char getHexChar(int n)
      Get the matching hex digit as a lower case character.
      Parameters:
      n - The value to get the hex digit from. Must be between 0 and 15.
      Returns:
      The hex character (one of 0-9 or a-f), or '\0' if the value could not be converted
    • getHexCharUpperCase

      public static char getHexCharUpperCase(int n)
      Get the matching hex digit as an upper case character.
      Parameters:
      n - The value to get the hex digit from. Must be between 0 and 15.
      Returns:
      The hex character (one of 0-9 or A-F), or '\0' if the value could not be converted
    • getHexEncoded

      @Nonnull public static String getHexEncoded(@Nonnull String sInput, @Nonnull Charset aCharset)
      Convert a string to a byte array and than to a hexadecimal encoded string.
      Parameters:
      sInput - The source string. May not be null.
      aCharset - The charset to use. May not be null.
      Returns:
      The String representation of the byte array of the string.
    • getHexEncoded

      @Nonnull public static String getHexEncoded(@Nonnull byte[] aInput)
      Convert a byte array to a hexadecimal encoded string.
      Parameters:
      aInput - The byte array to be converted to a String. May not be null.
      Returns:
      The String representation of the byte array.
    • getHexEncoded

      @Nonnull public static String getHexEncoded(@Nonnull byte[] aInput, int nOfs, int nLen)
      Convert a byte array to a hexadecimal encoded string.
      Parameters:
      aInput - The byte array to be converted to a String. May not be null.
      nOfs - Byte array offset
      nLen - Number of bytes to encode
      Returns:
      The String representation of the byte array.
    • getHexValue

      @CheckForSigned public static int getHexValue(@Nonnegative char c)
      Get the decimal value of the passed hex character
      Parameters:
      c - The hex char to convert (0-9, a-f, A-F)
      Returns:
      A value between 0 and 15, or -1 if the input character is not a hex char!
    • getHexByte

      public static int getHexByte(@Nonnegative char cHigh, @Nonnegative char cLow)
      Parameters:
      cHigh - High hex part
      cLow - Low hex part
      Returns:
      A value between 0 and 255, or -1 if any input character is not a hex char!
    • getHexDecoded

      @Nonnull @ReturnsMutableCopy public static byte[] getHexDecoded(@Nonnull String sInput)
    • getHexDecoded

      @Nonnull @ReturnsMutableCopy public static byte[] getHexDecoded(@Nonnull char[] aInput)
    • getHexDecoded

      @Nonnull @ReturnsMutableCopy public static byte[] getHexDecoded(@Nonnull char[] aInput, @Nonnegative int nOfs, @Nonnegative int nLen)
    • getHexString

      @Nonnull public static String getHexString(byte nValue)
    • getHexStringLeadingZero

      @Nonnull public static String getHexStringLeadingZero(byte nValue, int nDigits)
    • getHexStringLeadingZero2

      @Nonnull public static String getHexStringLeadingZero2(byte nValue)
    • getHexString

      @Nonnull public static String getHexString(int nValue)
    • getHexStringLeadingZero

      @Nonnull public static String getHexStringLeadingZero(int nValue, int nDigits)
    • getHexString

      @Nonnull public static String getHexString(long nValue)
    • getHexStringLeadingZero

      @Nonnull public static String getHexStringLeadingZero(long nValue, int nDigits)
    • getHexString

      @Nonnull public static String getHexString(short nValue)
    • getHexStringLeadingZero

      @Nonnull public static String getHexStringLeadingZero(short nValue, int nDigits)