Package org.apache.fluo.api.config
Class SimpleConfiguration
- java.lang.Object
-
- org.apache.fluo.api.config.SimpleConfiguration
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
FluoConfiguration
public class SimpleConfiguration extends Object implements Serializable
A simple configuration wrapper for Apache Commons configuration. The implementation supports reading and writing properties style config and interpolation.This simple wrapper was created to keep 3rd party APIs out of the Fluo API.
- Since:
- 1.0.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SimpleConfiguration()
SimpleConfiguration(File propertiesFile)
Read a properties style config from given file.SimpleConfiguration(InputStream in)
Read a properties style config from given input stream.SimpleConfiguration(Map<String,String> map)
SimpleConfiguration(SimpleConfiguration other)
Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
void
clearProperty(String key)
boolean
containsKey(String key)
boolean
equals(Object o)
boolean
getBoolean(String key)
boolean
getBoolean(String key, boolean defaultValue)
int
getInt(String key)
int
getInt(String key, int defaultValue)
Iterator<String>
getKeys()
Iterator<String>
getKeys(String key)
long
getLong(String key)
long
getLong(String key, long defaultValue)
String[]
getProperties(String key)
String
getRawString(String key)
String
getString(String key)
String
getString(String key, String defaultValue)
int
hashCode()
void
load(File file)
Loads configuration from File.void
load(InputStream in)
Loads configuration from InputStream.SimpleConfiguration
orElse(SimpleConfiguration fallback)
void
save(File file)
void
save(OutputStream out)
void
setProperties(String key, String... values)
void
setProperty(String key, Boolean value)
void
setProperty(String key, Integer value)
void
setProperty(String key, Long value)
void
setProperty(String key, String value)
SimpleConfiguration
subset(String prefix)
Returns a subset of config that start with given prefix.Map<String,String>
toMap()
String
toString()
-
-
-
Constructor Detail
-
SimpleConfiguration
public SimpleConfiguration()
-
SimpleConfiguration
public SimpleConfiguration(File propertiesFile)
Read a properties style config from given file.
-
SimpleConfiguration
public SimpleConfiguration(InputStream in)
Read a properties style config from given input stream.
-
SimpleConfiguration
public SimpleConfiguration(SimpleConfiguration other)
Copy constructor.
-
-
Method Detail
-
clear
public void clear()
-
clearProperty
public void clearProperty(String key)
-
containsKey
public boolean containsKey(String key)
-
getBoolean
public boolean getBoolean(String key)
-
getBoolean
public boolean getBoolean(String key, boolean defaultValue)
-
getInt
public int getInt(String key)
-
getInt
public int getInt(String key, int defaultValue)
-
getLong
public long getLong(String key)
-
getLong
public long getLong(String key, long defaultValue)
-
getRawString
public String getRawString(String key)
- Returns:
- raw property without interpolation or null if not set.
-
load
public void load(InputStream in)
Loads configuration from InputStream. Later loads have lower priority.- Parameters:
in
- InputStream to load from- Since:
- 1.2.0
-
load
public void load(File file)
Loads configuration from File. Later loads have lower priority.- Parameters:
file
- File to load from- Since:
- 1.2.0
-
save
public void save(File file)
-
save
public void save(OutputStream out)
-
subset
public SimpleConfiguration subset(String prefix)
Returns a subset of config that start with given prefix. The prefix will not be present in keys of the returned config. Any changes made to the returned config will be made to this and visa versa.
-
orElse
public SimpleConfiguration orElse(SimpleConfiguration fallback)
- Parameters:
fallback
- SimpleConfiguration to join together- Returns:
- a new simple configuration that contains all of the current properties from this plus the properties from fallback that are not present in this.
- Since:
- 1.2.0
-
-