code: private long fromHex(String s) {
      long result = 0;
      int size = s.length();
      for (int i = 0; i < size; i++) {
        char c = s.charAt(i);
        result *= 16;
        switch (c) {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
  	result += (c - '0');
  	break;
        case 'a':
        case 'b':
        case 'c':
        case 'd':
        case 'e':
        case 'f':
  	result += (c - 'a' + 10);
  	break;
        case 'A':
        case 'B':
        case 'C':
        case 'D':
        case 'E':
        case 'F':
  	result += (c - 'A' + 10);
  	break;
        default :
  	// TODO: throw a ParseException
        }
      }
      return result;
    }
docs: Convert a String representing a hex number to a long.