*/
@Validate
public static UnsignedLong fromAlphanumericToUInt64(@NotNull final String alphanumeric)
{
if (alphanumeric.equals(CONSTANT.ZERO))
return new UnsignedLong(BigInteger.ZERO);
UnsignedLong result = new UnsignedLong(BigInteger.ZERO);
BigInteger sixtyTwo = new BigInteger("62");
int len = alphanumeric.length();
for (int i = 0; i < len; i++)
{
char ch = alphanumeric.charAt(i);
if (!StringUtils.contains(CONSTANT.ALPHANUMERIC_DIGITS, ch))
throw new NumberFormatException("The digit does not belong to the alphanumeric number structure: " + ch);
// add and check for overflows
int pos = len - i - 1;
int charIndex = StringUtils.indexOf(CONSTANT.ALPHANUMERIC_DIGITS, ch);
BigInteger added = sixtyTwo.pow(pos).multiply(new BigInteger(charIndex + ""));
result = new UnsignedLong(result.bigIntegerValue().add(added));
}
return result;
}