class ConfigHelper {

  public static long parseByteSize(String sizeString) throws InvalidConfigException
  {
    if (null == sizeString) return 0;
    long unit = 1L;
    Matcher m = BYTE_SIZE_PATTERN.matcher(sizeString);
    if (!m.matches()) throw new InvalidConfigException("invalid byte-size string: " + sizeString);
    if (1 < m.groupCount() && null != m.group(2) && 0 < m.group(2).length())
    {
      char unitChar1 = m.group(2).charAt(0);
      switch (unitChar1)
      {
      case 'k': unit = 1000L; break;
      case 'K': unit = 1024L; break;
      case 'm': unit = 1000L * 1000L; break;
      case 'M': unit = 1024L * 1024L; break;
      case 'g': unit = 1000L * 1000L * 1000L; break;
      case 'G': unit = 1024L * 1024L * 1024L; break;
      case 't': unit = 1000L * 1000L * 1000L * 1000L; break;
      case 'T': unit = 1024L * 1024L * 1024L * 1024L; break;
      case 'p': unit = 1000L * 1000L * 1000L * 1000L * 1000L; break;
      case 'P': unit = 1024L * 1024L * 1024L * 1024L * 1024L; break;
      case 'e': unit = 1000L * 1000L * 1000L * 1000L * 1000L * 1000L; break;
      case 'E': unit = 1024L * 1024L * 1024L * 1024L * 1024L * 1024L; break;
      }
    }

    long value = Long.parseLong(m.group(1));
    return unit * value;

  }

}