/** * Parses a 1 to 32 character lower-hex string with no prefix into an unsigned long, tossing any * bits higher than 64. */ public static long lowerHexToUnsignedLong(String lowerHex) { int length = lowerHex.length(); if (length < 1 || length > 32) throw isntLowerHexLong(lowerHex); // trim off any high bits int beginIndex = length > 16 ? length - 16 : 0; return lowerHexToUnsignedLong(lowerHex, beginIndex); }
/** * @param hexString The lowercase hexadecimal string representing an unsigned 64-bit long that you want to convert to a Java long primitive. * @return The Java long primitive represented by the given lowercase hex string. If the string isn't lowercase hexadecimal encoded then a * {@link NumberFormatException} will be thrown. If the string is larger than 64-bits, any higher bits will be ignored. */ public static long unsignedLowerHexStringToLong(String hexString) { return ZipkinHexHelpers.lowerHexToUnsignedLong(hexString); }
/** * @param hexString The lowercase hexadecimal string representing an unsigned 64-bit long that you want to convert to a Java long primitive. * @param index index to read 16 hexadecimal characters from * @return The Java long primitive represented by the given lowercase hex string. If the string isn't lowercase hexadecimal encoded then a * {@link NumberFormatException} will be thrown. */ public static long unsignedLowerHexStringToLong(String hexString, int index) { return ZipkinHexHelpers.lowerHexToUnsignedLong(hexString, index); }