Class TypedProperties

All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>
Direct Known Subclasses:
Options

public class TypedProperties extends Properties
A specialization of the Properties map type with added convenience methods to retrieve and set options as primitive values. The internal representation of all data is kept in string form.
Author:
Abe White
See Also:
  • Constructor Details

    • TypedProperties

      public TypedProperties()
      Default constructor.
    • TypedProperties

      public TypedProperties(Properties defaults)
      Construct the properties instance with the given set of defaults.
      See Also:
  • Method Details

    • getBooleanProperty

      public boolean getBooleanProperty(String key)
      Return the property under the given key as a boolean, or false if it does not exist and has no set default.
    • getBooleanProperty

      public boolean getBooleanProperty(String key, boolean def)
      Return the property under the given key as a boolean, or the given default if it does not exist.
    • getFloatProperty

      public float getFloatProperty(String key)
      Return the property under the given key as a float, or 0 if it does not exist and has no set default.
      Throws:
      NumberFormatException - on parse error
    • getFloatProperty

      public float getFloatProperty(String key, float def)
      Return the property under the given key as a float, or the given default if it does not exist.
      Throws:
      NumberFormatException - on parse error
    • getDoubleProperty

      public double getDoubleProperty(String key)
      Return the property under the given key as a double, or 0 if it does not exist and has no set default.
      Throws:
      NumberFormatException - on parse error
    • getDoubleProperty

      public double getDoubleProperty(String key, double def)
      Return the property under the given key as a double, or the given default if it does not exist.
      Throws:
      NumberFormatException - on parse error
    • getLongProperty

      public long getLongProperty(String key)
      Return the property under the given key as a long, or 0 if it does not exist and has no set default.
      Throws:
      NumberFormatException - on parse error
    • getLongProperty

      public long getLongProperty(String key, long def)
      Return the property under the given key as a double, or the given default if it does not exist.
      Throws:
      NumberFormatException - on parse error
    • getIntProperty

      public int getIntProperty(String key)
      Return the property under the given key as an int, or 0 if it does not exist and has no set default.
      Throws:
      NumberFormatException - on parse error
    • getIntProperty

      public int getIntProperty(String key, int def)
      Return the property under the given key as an int, or the given default if it does not exist.
      Throws:
      NumberFormatException - on parse error
    • setProperty

      public Object setProperty(String key, String val)
      Overrides Properties.setProperty(String,String) to remove the key if the given value is null.
      Overrides:
      setProperty in class Properties
      See Also:
    • setProperty

      public void setProperty(String key, boolean val)
      Set the given key to a string version of the given value.
      See Also:
    • setProperty

      public void setProperty(String key, double val)
      Set the given key to a string version of the given value.
      See Also:
    • setProperty

      public void setProperty(String key, float val)
      Set the given key to a string version of the given value.
      See Also:
    • setProperty

      public void setProperty(String key, int val)
      Set the given key to a string version of the given value.
      See Also:
    • setProperty

      public void setProperty(String key, long val)
      Set the given key to a string version of the given value.
      See Also:
    • removeProperty

      public String removeProperty(String key)
      Remove the given property.
    • removeProperty

      public String removeProperty(String key, String def)
      Remove the given property, or return the given default if it does not exist.
    • removeBooleanProperty

      public boolean removeBooleanProperty(String key)
      Remove the property under the given key as a boolean.
    • removeBooleanProperty

      public boolean removeBooleanProperty(String key, boolean def)
      Remove the property under the given key as a boolean, or return the given default if it does not exist.
    • removeDoubleProperty

      public double removeDoubleProperty(String key)
      Remove the property under the given key as a double.
      Throws:
      NumberFormatException - on parse error
    • removeDoubleProperty

      public double removeDoubleProperty(String key, double def)
      Remove the property under the given key as a double, or return the given default if it does not exist.
      Throws:
      NumberFormatException - on parse error
    • removeFloatProperty

      public float removeFloatProperty(String key)
      Remove the property under the given key as a float.
      Throws:
      NumberFormatException - on parse error
    • removeFloatProperty

      public float removeFloatProperty(String key, float def)
      Remove the property under the given key as a float, or return the given default if it does not exist.
      Throws:
      NumberFormatException - on parse error
    • removeIntProperty

      public int removeIntProperty(String key)
      Remove the property under the given key as a int.
      Throws:
      NumberFormatException - on parse error
    • removeIntProperty

      public int removeIntProperty(String key, int def)
      Remove the property under the given key as a int, or return the given default if it does not exist.
      Throws:
      NumberFormatException - on parse error
    • removeLongProperty

      public long removeLongProperty(String key)
      Remove the property under the given key as a long.
      Throws:
      NumberFormatException - on parse error
    • removeLongProperty

      public long removeLongProperty(String key, long def)
      Remove the property under the given key as a long, or return the given default if it does not exist.
      Throws:
      NumberFormatException - on parse error