Пример #1
0
  public Long kiloCfg(String key, Long defval) {
    String s = properties.getProperty(key);

    long multi = 1L;

    if (s != null) {
      Matcher matcher = kiloRe.matcher(s);

      if (matcher.matches()) {
        s = matcher.group(1);
        multi = kilos.get(matcher.group(2));
      }
    }

    try {
      if (s != null) {
        return Long.parseLong(s.trim()) * multi;
      } else {
        return defval;
      }
    } catch (NumberFormatException e) {
      log.error(
          "Cannot parse key '"
              + key
              + "' -> '"
              + s
              + "'. Returning default value of "
              + defval
              + ".",
          e);
      return defval;
    }
  }
Пример #2
0
  public Long longCfg(String key, Long defval) {
    String s = properties.getProperty(key);

    try {
      if (s != null) {
        return Long.parseLong(s.trim());
      } else {
        return defval;
      }
    } catch (NumberFormatException e) {
      log.error(
          "Cannot parse key '"
              + key
              + "' -> '"
              + s
              + "'. Returning default value of "
              + defval
              + ".",
          e);
      return defval;
    }
  }