Exemplo n.º 1
0
  /** Helper method. Gets a double by key. Returns 0 if no property exists or it is malformed */
  public static double getAsDouble(String key) {

    String i = Parameters.getString(key);

    try {
      return Double.valueOf(i).doubleValue();
    } catch (NumberFormatException e) {
      System.err.println("Malformed double in properties for key=" + key + ":" + i);
    }
    return 0.0;
  }
Exemplo n.º 2
0
  /** Helper method. Gets an integer by key. Returns 0 if no property exists or it is malformed */
  public static int getAsInteger(String key) {

    String i = Parameters.getString(key);

    try {
      return Integer.parseInt(i);
    } catch (NumberFormatException e) {
      System.err.println("Malformed integer in properties for key=" + key + ":" + i);
    }
    return 0;
  }
Exemplo n.º 3
0
  public static Object getObject(String key) {

    return instance.get(key);
  }
Exemplo n.º 4
0
  /**
   * Helper method. Gets a boolean by key. Returns true only if the property is true in either case
   */
  public static boolean getAsBoolean(String key) {

    String s = Parameters.getString(key);
    return str2Bool(s);
  }
Exemplo n.º 5
0
  /** Returns a property by key as String */
  public static String getString(String key) {

    String value = instance.getProperty(key);
    return (value != null ? value.trim() : null);
  }
Exemplo n.º 6
0
  /** Adds a property overriding the old value if the value with the same key exists already */
  public static void addProperty(String key, String value) {

    instance.put(key, value);
  }