Class Configuration
- java.lang.Object
-
- fr.ens.biologie.genomique.aozan.aozan3.Configuration
-
- Direct Known Subclasses:
RunConfiguration
public class Configuration extends Object
This class define a configuration- Since:
- 3.0
- Author:
- Laurent Jourdren
-
-
Constructor Summary
Constructors Constructor Description Configuration()Default constructor.Configuration(Configuration conf)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(String key)Test if configuration contains a key.Stringget(String key)Get the value for a configuration key.Stringget(String key, String defaultValue)Get the value for a configuration key.booleangetBoolean(String key)Get a boolean configuration key.booleangetBoolean(String key, boolean defaultValue)Get a boolean value for a configuration key.doublegetDouble(String key)Get a double configuration key.doublegetDouble(String key, double defaultValue)Get a double value for a configuration key.intgetInt(String key)Get an int configuration key.intgetInt(String key, int defaultValue)Get an integer value for a configuration key.longgetLong(String key)Get a long configuration key.longgetLong(String key, long defaultValue)Get a long value for a configuration key.PathgetPath(String key)Get Path configuration key.PathgetPath(String key, Path defaultValue)Get a Path value for a configuration key.booleanisEmpty()Test if the configuration is empty.voidload(Path file)Load configuration.voidload(Path file, boolean aozan2Compatibility)Load configuration.voidparseAndSet(String s)Parse a string (e.g.voidset(Configuration conf)Add all the keys and value of a Configuration object in this one.voidset(String key, boolean value)Set a value.voidset(String key, Number value)Set a value.voidset(String key, String value)Set a value.voidsetFromOtherConf(Configuration conf, String key)Set a value from the value of another configuration.voidsetFromOtherConf(Configuration conf, String key, String defaultValue)Set a value from the value of another configuration.voidsetFromOtherConfIfExists(Configuration conf, String key)Set a value from the value of another configuration.voidsetIfNotExists(String key, boolean value)Set a value if key does not exists.voidsetIfNotExists(String key, Number value)Set a value if key does not exists.voidsetIfNotExists(String key, String value)Set a value if key does not exists.intsize()Return the size of the configuration.Map<String,String>toMap()Convert the configuration as a Map.StringtoString()
-
-
-
Constructor Detail
-
Configuration
public Configuration()
Default constructor.
-
Configuration
public Configuration(Configuration conf)
Constructor.- Parameters:
conf- configuration to copy
-
-
Method Detail
-
containsKey
public boolean containsKey(String key)
Test if configuration contains a key.- Parameters:
key- the key to test- Returns:
- true if the configuration contains the key
-
get
public String get(String key)
Get the value for a configuration key.- Parameters:
key- the key. The key must exists- Returns:
- a String with the value
-
getBoolean
public boolean getBoolean(String key)
Get a boolean configuration key.- Parameters:
key- the key The key must exists- Returns:
- a boolean value
-
getInt
public int getInt(String key)
Get an int configuration key.- Parameters:
key- the key The key must exists- Returns:
- a integer value
-
getLong
public long getLong(String key)
Get a long configuration key.- Parameters:
key- the key The key must exists- Returns:
- a long value
-
getDouble
public double getDouble(String key)
Get a double configuration key.- Parameters:
key- the key The key must exists- Returns:
- a double value
-
getPath
public Path getPath(String key)
Get Path configuration key.- Parameters:
key- the key The key must exists- Returns:
- a Path value
-
get
public String get(String key, String defaultValue)
Get the value for a configuration key.- Parameters:
key- the keydefaultValue- value if the key does not exists- Returns:
- a String with the value
-
getBoolean
public boolean getBoolean(String key, boolean defaultValue)
Get a boolean value for a configuration key.- Parameters:
key- the keydefaultValue- value if the key does not exists- Returns:
- a String with the value
-
getInt
public int getInt(String key, int defaultValue)
Get an integer value for a configuration key.- Parameters:
key- the keydefaultValue- value if the key does not exists- Returns:
- a integer
-
getLong
public long getLong(String key, long defaultValue)
Get a long value for a configuration key.- Parameters:
key- the keydefaultValue- value if the key does not exists- Returns:
- a long
-
getDouble
public double getDouble(String key, double defaultValue)
Get a double value for a configuration key.- Parameters:
key- the keydefaultValue- value if the key does not exists- Returns:
- a double
-
getPath
public Path getPath(String key, Path defaultValue)
Get a Path value for a configuration key.- Parameters:
key- the keydefaultValue- value if the key does not exists- Returns:
- a Path
-
set
public void set(String key, String value)
Set a value.- Parameters:
key- the keyvalue- the value
-
setIfNotExists
public void setIfNotExists(String key, String value)
Set a value if key does not exists.- Parameters:
key- the keyvalue- the value
-
set
public void set(String key, boolean value)
Set a value.- Parameters:
key- the keyvalue- the value
-
setIfNotExists
public void setIfNotExists(String key, boolean value)
Set a value if key does not exists.- Parameters:
key- the keyvalue- the value
-
set
public void set(String key, Number value)
Set a value.- Parameters:
key- the keyvalue- the value
-
setIfNotExists
public void setIfNotExists(String key, Number value)
Set a value if key does not exists.- Parameters:
key- the keyvalue- the value
-
set
public void set(Configuration conf)
Add all the keys and value of a Configuration object in this one.- Parameters:
conf- the configuration to add
-
setFromOtherConf
public void setFromOtherConf(Configuration conf, String key)
Set a value from the value of another configuration.- Parameters:
conf- the configuration where retriving the valuekey- the ley
-
setFromOtherConfIfExists
public void setFromOtherConfIfExists(Configuration conf, String key)
Set a value from the value of another configuration.- Parameters:
conf- the configuration where retriving the valuekey- the ley
-
setFromOtherConf
public void setFromOtherConf(Configuration conf, String key, String defaultValue)
Set a value from the value of another configuration.- Parameters:
conf- the configuration where retrieving the valuekey- the keydefaultValue- value if the key does not exists
-
parseAndSet
public void parseAndSet(String s)
Parse a string (e.g. key=value) and set the key and value in the configuration.- Parameters:
s- String to parse
-
toMap
public Map<String,String> toMap()
Convert the configuration as a Map.- Returns:
- a copy of the configuration object in a map
-
size
public int size()
Return the size of the configuration.- Returns:
- the number of elements in the configuration
-
isEmpty
public boolean isEmpty()
Test if the configuration is empty.- Returns:
- true if the configuration is empty
-
load
public void load(Path file) throws Aozan3Exception
Load configuration.- Parameters:
file- file to save- Throws:
Aozan3Exception- if an error occurs while reading the file
-
load
public void load(Path file, boolean aozan2Compatibility) throws Aozan3Exception
Load configuration.- Parameters:
file- file to save- Throws:
Aozan3Exception- if an error occurs while reading the file
-
-