예제 #1
0
  public static int getIntegerProperty(
      final String propertyName, final int defaultValue, final PropertyFileLoader fileLoader) {
    final String value = fileLoader.getProperty(propertyName);
    Integer returnValue = defaultValue;

    try {
      returnValue = Integer.valueOf(value);
    } catch (NumberFormatException e) {
      logger.error("Invalid number format " + value);
    }

    fileLoader.setProperty(propertyName, String.valueOf(returnValue));
    return returnValue;
  }
예제 #2
0
  public static boolean getBooleanProperty(
      final String propertyName, final boolean defaultValue, final PropertyFileLoader fileLoader) {
    final String value = fileLoader.getProperty(propertyName);
    Boolean returnValue = defaultValue;

    // Default, when non present is X
    if (value == null || value.isEmpty()) {
      returnValue = defaultValue;
    } else {
      try {
        returnValue = Boolean.valueOf(value);
      } catch (IllegalArgumentException e) {
        logger.error("Invalid format " + value);
      }
    }

    fileLoader.setProperty(propertyName, String.valueOf(returnValue));
    return returnValue;
  }