Class Properties

All Implemented Interfaces:
Serializable, Cloneable, Configuration, EventSource, FileBasedConfiguration, ImmutableConfiguration, FileBased, FileLocatorAware, SynchronizerSupport

public class Properties extends PropertiesConfiguration implements Serializable
An extension of PropertiesConfiguration providing setters for primitive types, a simpler way to save preferences and transparent handling of Enum lowercased keys.

All accessors defined in PropertiesConfiguration have a polymorphic counterpart taking an Enum instead of a string: Enum.name() and String.toLowerCase() are applied before delegating to the corresponding string-based method. (This apparently wierd choice is due to the need to accommodate the upper-case standard for Enum elements and the lower-case standard for property keys.)

Additionally, instances of this class can be serialised.

See Also:
  • Constructor Details

  • Method Details

    • save

      public void save(CharSequence filename) throws ConfigurationException, IOException
      Saves the configuration to the specified file.
      Parameters:
      filename - a file name.
      Throws:
      ConfigurationException
      IOException
    • save

      public void save(File file) throws ConfigurationException, IOException
      Saves the configuration to the specified file.
      Parameters:
      file - a file.
      Throws:
      ConfigurationException
      IOException
    • save

      public void save(OutputStream os) throws ConfigurationException
      Saves the configuration to an output stream.
      Parameters:
      os - an output stream.
      Throws:
      ConfigurationException
    • load

      public void load(CharSequence filename) throws ConfigurationException, IOException
      Loads a configuration from a specified file.
      Parameters:
      filename - a file name.
      Throws:
      ConfigurationException
      IOException
    • load

      public void load(File file) throws ConfigurationException, IOException
      Loads a configuration from a specified file.
      Parameters:
      file - a file.
      Throws:
      ConfigurationException
      IOException
    • load

      public void load(InputStream is) throws ConfigurationException
      Loads a configuration from an input stream.
      Parameters:
      is - an input stream.
      Throws:
      ConfigurationException
    • addAll

      public void addAll(Configuration configuration)
      Adds all properties from the given configuration.

      Properties from the new configuration will clear properties from the first one.

      Parameters:
      configuration - a configuration.
    • addProperties

      public void addProperties(String key, String[] s)
    • addProperty

      public void addProperty(String key, boolean b)
    • setProperty

      public void setProperty(String key, boolean b)
    • addProperty

      public void addProperty(String key, byte b)
    • setProperty

      public void setProperty(String key, byte b)
    • addProperty

      public void addProperty(String key, short s)
    • setProperty

      public void setProperty(String key, short s)
    • addProperty

      public void addProperty(String key, char c)
    • setProperty

      public void setProperty(String key, char b)
    • addProperty

      public void addProperty(String key, int i)
    • setProperty

      public void setProperty(String key, int i)
    • addProperty

      public void addProperty(String key, long l)
    • setProperty

      public void setProperty(String key, long l)
    • addProperty

      public void addProperty(String key, float f)
    • setProperty

      public void setProperty(String key, float f)
    • addProperty

      public void addProperty(String key, double d)
    • setProperty

      public void setProperty(String key, double d)
    • addProperties

      public void addProperties(Enum<?> key, String[] s)
    • addProperty

      public void addProperty(Enum<?> key, boolean b)
    • setProperty

      public void setProperty(Enum<?> key, boolean b)
    • addProperty

      public void addProperty(Enum<?> key, byte b)
    • setProperty

      public void setProperty(Enum<?> key, byte b)
    • addProperty

      public void addProperty(Enum<?> key, short s)
    • setProperty

      public void setProperty(Enum<?> key, short s)
    • addProperty

      public void addProperty(Enum<?> key, char c)
    • setProperty

      public void setProperty(Enum<?> key, char b)
    • addProperty

      public void addProperty(Enum<?> key, int i)
    • setProperty

      public void setProperty(Enum<?> key, int i)
    • addProperty

      public void addProperty(Enum<?> key, long l)
    • setProperty

      public void setProperty(Enum<?> key, long l)
    • addProperty

      public void addProperty(Enum<?> key, float f)
    • setProperty

      public void setProperty(Enum<?> key, float f)
    • addProperty

      public void addProperty(Enum<?> key, double d)
    • setProperty

      public void setProperty(Enum<?> key, double d)
    • containsKey

      public boolean containsKey(Enum<?> key)
    • getProperty

      public Object getProperty(Enum<?> key)
    • addProperty

      public void addProperty(Enum<?> key, Object arg)
    • getBigDecimal

      public BigDecimal getBigDecimal(Enum<?> key, BigDecimal arg)
    • getBigDecimal

      public BigDecimal getBigDecimal(Enum<?> key)
    • getBigInteger

      public BigInteger getBigInteger(Enum<?> key, BigInteger arg)
    • getBigInteger

      public BigInteger getBigInteger(Enum<?> key)
    • getBoolean

      public boolean getBoolean(Enum<?> key, boolean arg)
    • getBoolean

      public Boolean getBoolean(Enum<?> key, Boolean arg)
    • getBoolean

      public boolean getBoolean(Enum<?> key)
    • getByte

      public byte getByte(Enum<?> key, byte arg)
    • getByte

      public Byte getByte(Enum<?> key, Byte arg)
    • getByte

      public byte getByte(Enum<?> key)
    • getDouble

      public double getDouble(Enum<?> key, double arg)
    • getDouble

      public Double getDouble(Enum<?> key, Double arg)
    • getDouble

      public double getDouble(Enum<?> key)
    • getFloat

      public float getFloat(Enum<?> key, float arg)
    • getFloat

      public Float getFloat(Enum<?> key, Float arg)
    • getFloat

      public float getFloat(Enum<?> key)
    • getInt

      public int getInt(Enum<?> key, int arg)
    • getInt

      public int getInt(Enum<?> key)
    • getInteger

      public Integer getInteger(Enum<?> key, Integer arg)
    • getKeys

      public Iterator<?> getKeys(Enum<?> key)
    • getList

      public List<Object> getList(Enum<?> key, List<Object> arg)
    • getList

      public List<?> getList(Enum<?> key)
    • getLong

      public long getLong(Enum<?> key, long arg)
    • getLong

      public Long getLong(Enum<?> key, Long arg)
    • getLong

      public long getLong(Enum<?> key)
    • getProperties

      public Properties getProperties(Enum<?> key, Properties arg)
    • getProperties

      public Properties getProperties(Enum<?> key)
    • getShort

      public short getShort(Enum<?> key, short arg)
    • getShort

      public Short getShort(Enum<?> key, Short arg)
    • getShort

      public short getShort(Enum<?> key)
    • getString

      public String getString(Enum<?> key, String arg)
    • getString

      public String getString(Enum<?> key)
    • getStringArray

      public String[] getStringArray(Enum<?> key)
    • setProperty

      public void setProperty(Enum<?> key, Object arg)
    • subset

      public Configuration subset(Enum<?> key)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Returns true if the provided object is equal to this set of properties.

      Equality between set of properties happens when the keys are the same, and the list of strings associated with each key is the same. Note that the order in which different keys appear in a property file is irrelevant, but the order between properties with the same key is significant.

      Due to the strictness of the check (e.g., no number conversion is performed) this method is mainly useful when writing tests.

      Overrides:
      equals in class Object
      Returns:
      true if the argument is equal to this set of properties.