Configuration

public class Configuration

Manages a list of configurable properties and allows for saving to/loading from a file.

Author:Tim

Constructors

Configuration

public Configuration()

Methods

containsKey

public boolean containsKey(String key)

get

public Object get(String key)

get

public <T> T get(String key, T fallback)
Parameters:
  • key – The name of the property to get.
  • fallback – A value to use if no such property is set.

getBoolean

public Boolean getBoolean(String key)

Get a boolean property

Parameters:
  • key

getBoolean

public Boolean getBoolean(String key, boolean fallback)
Parameters:
  • key – The name of the property to get.
  • fallback – A value to use if no such property is set.

getDouble

public Double getDouble(String key)

getDouble

public Double getDouble(String key, Double fallback)
Parameters:
  • key – The name of the property to get.
  • fallback – A value to use if no such property is set.

getInt

public Integer getInt(String key)
Parameters:
  • key

getInt

public Integer getInt(String key, int fallback)

Get an integer property

Parameters:
  • key – The name of the property to get.
  • fallback – A value to use if no such property is set.

getKeys

public Set<String> getKeys()

getString

public String getString(String key)

getString

public String getString(String key, String fallback)
Parameters:
  • key – The name of the property to get.
  • fallback – A value to use if no such property is set.

loadPreferenceFormatConfiguration

public static Configuration loadPreferenceFormatConfiguration(String configFilePath)

Treat a file as a java preferences file and load it into a configuration, without the unsafe use of java’s preferences.

Parameters:
  • configFilePath
Returns:

a configuration parsed from the file

put

public void put(String key, String value)

put

public void put(String key, boolean value)

put

public void put(String key, int value)

put

public void put(String key, double value)

put

public <T> void put(String key, T value)

toString

public String toString()