public class YConfiguration extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
YConfiguration.ConfigurationNotFoundException
Introduced to be able to detect when a configuration file was not
specified (as opposed to when there's a validation error inside).
|
static class |
YConfiguration.DefaultConfigurationResolver
Default config file resolver.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(String key) |
boolean |
containsKey(String key,
String key1) |
static boolean |
getBoolean(Map<String,Object> m,
String key) |
static boolean |
getBoolean(Map<String,Object> m,
String key,
boolean defaultValue)
Returns m.get(key) if it exists and is of type boolean,
if m.get(key) exists and is not boolean, throw an exception.
|
boolean |
getBoolean(String key) |
boolean |
getBoolean(String key,
boolean defaultValue) |
boolean |
getBoolean(String key,
String key1) |
boolean |
getBoolean(String key,
String key1,
String key2) |
static YConfiguration |
getConfiguration(String subsystem)
Loads (if not already loaded) and returns a configuration corresponding to a file <subsystem>.yaml
This method does not reload the configuration file if it has changed.
|
static YConfiguration |
getConfiguration(String subsystem,
boolean reload)
Loads and returns a configuration corresponding to a file <subsystem>.yaml
This method reloads the configuration file always.
|
String |
getFirstEntry()
returns the first entry(key) in the config file.
|
Map<String,Object> |
getFirstMap()
returns the first entry in the config file if it's a map.
|
static String |
getGlobalProperty(String key) |
static int |
getInt(Map<String,Object> m,
String key)
int configs
|
static int |
getInt(Map<String,Object> m,
String key,
int defaultValue)
return the m.get(key) as an int if it's present or v if it is not.
|
int |
getInt(String key) |
int |
getInt(String key,
String key1) |
int |
getInt(String key,
String key1,
int defaultValue) |
Set<String> |
getKeys() |
static <T> List<T> |
getList(Map<String,Object> m,
String key)
List configs
|
<T> List<T> |
getList(String key) |
<T> List<T> |
getList(String key,
String key1) |
<T> List<T> |
getList(String key,
String key1,
String key2) |
static long |
getLong(Map<String,Object> m,
String key) |
static long |
getLong(Map<String,Object> m,
String key,
long v)
return the m.get(key) as an long if it's present or v if it is not.
|
static Map<String,Object> |
getMap(Map<String,Object> m,
String key)
Map configs
|
Map<String,Object> |
getMap(String key) |
Map<String,Object> |
getMap(String key,
String key1) |
static String |
getString(Map m,
String key)
Returns m.get(key) if it exists and is of type string, otherwise throws an exception
|
static String |
getString(Map m,
String key,
String defaultValue) |
String |
getString(String key) |
String |
getString(String key,
String subkey) |
String |
getString(String key,
String key1,
String key2) |
static boolean |
isDefined(String subsystem) |
static boolean |
isList(Map m,
String key) |
boolean |
isList(String key) |
static void |
setResolver(YConfigurationResolver resolver) |
static void |
setup()
calls setup(null)
|
static void |
setup(String configPrefix)
If configPrefix is not null, sets up the configuration to search the classpath for files like "configPrefix/xyz.properties"
Also sets up the TimeEncoding configuration
|
static void |
setup(String configPrefix,
String userConfigDirectory) |
public static void setup(String configPrefix) throws ConfigurationException
configPrefix - ConfigurationExceptionpublic static void setup()
throws ConfigurationException
ConfigurationExceptionpublic static YConfiguration getConfiguration(String subsystem) throws ConfigurationException
subsystem - ConfigurationException - if the configuration file could not be found or not loaded (e.g. error in yaml formatting)public static YConfiguration getConfiguration(String subsystem, boolean reload) throws ConfigurationException
subsystem - reload - ConfigurationException - if the configuration file could not be found or not loaded (e.g. error in yaml formatting)public static boolean isDefined(String subsystem) throws ConfigurationException
ConfigurationExceptionpublic boolean containsKey(String key)
public boolean containsKey(String key, String key1) throws ConfigurationException
ConfigurationExceptionpublic Map<String,Object> getFirstMap() throws ConfigurationException
ConfigurationExceptionpublic String getFirstEntry() throws ConfigurationException
ConfigurationExceptionpublic static Map<String,Object> getMap(Map<String,Object> m, String key) throws ConfigurationException
ConfigurationExceptionpublic Map<String,Object> getMap(String key) throws ConfigurationException
ConfigurationExceptionpublic Map<String,Object> getMap(String key, String key1) throws ConfigurationException
ConfigurationExceptionpublic static String getString(Map m, String key) throws ConfigurationException
m - key - ConfigurationExceptionpublic static String getString(Map m, String key, String defaultValue) throws ConfigurationException
ConfigurationExceptionpublic String getString(String key) throws ConfigurationException
ConfigurationExceptionpublic String getString(String key, String subkey) throws ConfigurationException
ConfigurationExceptionpublic String getString(String key, String key1, String key2) throws ConfigurationException
ConfigurationExceptionpublic <T> List<T> getList(String key) throws ConfigurationException
ConfigurationExceptionpublic static <T> List<T> getList(Map<String,Object> m, String key) throws ConfigurationException
ConfigurationExceptionpublic <T> List<T> getList(String key, String key1, String key2) throws ConfigurationException
ConfigurationExceptionpublic <T> List<T> getList(String key, String key1) throws ConfigurationException
ConfigurationExceptionpublic static boolean getBoolean(Map<String,Object> m, String key, boolean defaultValue) throws ConfigurationException
m - key - defaultValue - - the default value to return if m.get(key) does not exist.ConfigurationExceptionpublic static boolean getBoolean(Map<String,Object> m, String key) throws ConfigurationException
ConfigurationExceptionpublic boolean getBoolean(String key) throws ConfigurationException
ConfigurationExceptionpublic boolean getBoolean(String key, String key1) throws ConfigurationException
ConfigurationExceptionpublic boolean getBoolean(String key, String key1, String key2) throws ConfigurationException
ConfigurationExceptionpublic boolean getBoolean(String key, boolean defaultValue)
public static int getInt(Map<String,Object> m, String key) throws ConfigurationException
ConfigurationExceptionpublic static int getInt(Map<String,Object> m, String key, int defaultValue) throws ConfigurationException
m - key - defaultValue - ConfigurationException - if the key is present but it's not an intpublic static long getLong(Map<String,Object> m, String key) throws ConfigurationException
ConfigurationExceptionpublic static long getLong(Map<String,Object> m, String key, long v) throws ConfigurationException
m - key - v - ConfigurationException - if the key is present but it's not an longpublic int getInt(String key) throws ConfigurationException
ConfigurationExceptionpublic int getInt(String key, String key1) throws ConfigurationException
ConfigurationExceptionpublic int getInt(String key, String key1, int defaultValue) throws ConfigurationException
ConfigurationExceptionpublic boolean isList(String key)
public static void setResolver(YConfigurationResolver resolver)
Copyright © 2017 Space Applications Services. All rights reserved.