Package io.ultreia.java4all.config
Class SubApplicationConfig
- java.lang.Object
-
- io.ultreia.java4all.config.ApplicationConfig
-
- io.ultreia.java4all.config.SubApplicationConfig
-
public class SubApplicationConfig extends ApplicationConfig
Permet de masquer un prefix. Il est possible d'avoir des valeurs par defaut. Par exemple:monOption=toto monPrefix.monOption=titi
- Si on cree le subApp avec le prefix "monPrefix." et qu'on demande la valeur de "monOption", la valeur retournee est "titi".
- Si on cree le subApp avec le prefix "monAutrePrefix." et qu'on demande la valeur de "monOption", la valeur retournee est "toto" (valeur par defaut de monOption.
- getOptions()
- Since:
- 2.4.9
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.ultreia.java4all.config.ApplicationConfig
ApplicationConfig.Action, ApplicationConfig.CacheItem<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected ApplicationConfigparentprotected Stringprefix-
Fields inherited from class io.ultreia.java4all.config.ApplicationConfig
actions, aliases, APP_NAME, cacheAction, cacheOption, CLASS_METHOD_SEPARATOR, CONFIG_ENCODING, CONFIG_FILE_NAME, CONFIG_PATH, configStorage, context, EXTRA_CONFIG_DIRECTORY, inParseOptionPhase, LIST_SEPARATOR, osName, propertiesByScope, unparsed, useOnlyAliases
-
-
Constructor Summary
Constructors Constructor Description SubApplicationConfig(ApplicationConfig parent, String prefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PropertiesgetFlatOptions(boolean replaceInner)Surcharge de la methode pour que les options commencant par le prefix soit modifiee pour qu'elle est la meme cle sans le prefix.StringgetOption(String key)Surcharge pour recherche la cle avec le prefix.PropertiesgetOptions()Get all options from configuration.PropertiesgetOptionStartsWith(String prefix)Surcharge pour recupere les valeurs commencant par le prefix demande en plus du prefix 'sub'.ApplicationConfiggetParent()StringgetPrefix()booleanhasOption(String key)Teste si un option existe ou non.protected voidinit(ApplicationConfigInit init)On sépare l'initialisation du constructeur pour pouvoir ne pas exécuter ce code sur des classes surchargeant ApplicationConfigApplicationConfigparse(String... args)Parse option and call set necessary method, read jvm, env variable, Load configuration file and prepare Action.voidsetDefaultOption(String key, String value)Used to put default configuration option in config option.voidsetOption(String key, String value)Set option value.-
Methods inherited from class io.ultreia.java4all.config.ApplicationConfig
addAction, addActionAlias, addAlias, cleanUserConfig, convertOption, createAction, doAction, doAllAction, fixFileOptionsForWindows, getActionStep, getCharset, getConfig, getConfigFileName, getConfigFileNameOption, getConfigPath, getCurrentConfigFile, getEncoding, getEncodingOption, getExtraConfigDirectory, getExtraConfigDirectoryOption, getExtraConfigFile, getFlatOptions, getMethods, getObject, getObject, getOption, getOption, getOptionAsBoolean, getOptionAsClass, getOptionAsColor, getOptionAsDate, getOptionAsDouble, getOptionAsFile, getOptionAsFloat, getOptionAsInt, getOptionAsKeyStroke, getOptionAsList, getOptionAsLocale, getOptionAsLong, getOptionAsObject, getOptionAsObject, getOptionAsProperties, getOptionAsSingleton, getOptionAsSingleton, getOptionAsTime, getOptionAsTimestamp, getOptionAsURL, getOptionAsVersion, getOsArch, getOsName, getParams, getPrintableConfig, getProperties, getPropertiesToSave, getSubConfig, getSystemConfigFile, getSystemConfigurationPath, getUnparsed, getUserConfigDirectory, getUserConfigFile, getUserHome, getUsername, hasOption, isUseOnlyAliases, isWindowsOs, loadActions, loadDefaultOptions, loadResource, loadResourceProperty, printConfig, printConfig, putAll, putObject, putObject, remove, replaceRecursiveOptions, save, saveForCurrent, saveForExtra, saveForSystem, saveForUser, saveResource, setAppName, setConfigFileName, setEncoding, setExtraConfigDirectory, setOptions, setPropertiesMigration, setUseOnlyAliases
-
-
-
-
Field Detail
-
parent
protected ApplicationConfig parent
-
prefix
protected String prefix
-
-
Constructor Detail
-
SubApplicationConfig
public SubApplicationConfig(ApplicationConfig parent, String prefix)
-
-
Method Detail
-
init
protected void init(ApplicationConfigInit init)
Description copied from class:ApplicationConfigOn sépare l'initialisation du constructeur pour pouvoir ne pas exécuter ce code sur des classes surchargeant ApplicationConfig- Overrides:
initin classApplicationConfig- Parameters:
init- l'objet d'initialisation de l'applicationConfig
-
getParent
public ApplicationConfig getParent()
-
getPrefix
public String getPrefix()
-
getOptions
public Properties getOptions()
Description copied from class:ApplicationConfigGet all options from configuration.- Overrides:
getOptionsin classApplicationConfig- Returns:
- Properties which contains all options
-
setDefaultOption
public void setDefaultOption(String key, String value)
Description copied from class:ApplicationConfigUsed to put default configuration option in config option. Those options are used as fallback value.- Overrides:
setDefaultOptionin classApplicationConfig- Parameters:
key- default property keyvalue- default property value
-
hasOption
public boolean hasOption(String key)
Description copied from class:ApplicationConfigTeste si un option existe ou non.- Overrides:
hasOptionin classApplicationConfig- Parameters:
key- la clef de l'option à tester- Returns:
truesi l'option existe,falsesinon.
-
setOption
public void setOption(String key, String value)
Description copied from class:ApplicationConfigSet option value. If the value is null, then the option is removed.- Overrides:
setOptionin classApplicationConfig- Parameters:
key- property keyvalue- property value
-
getOption
public String getOption(String key)
Surcharge pour recherche la cle avec le prefix. Si on ne la retrouve pas, on recherche sans le prefixe pour permettre d'avoir des valeurs par défaut.- Overrides:
getOptionin classApplicationConfig- Parameters:
key- La cle de l'option- Returns:
- l'option trouvée avec le prefixe ou sinon celle sans le prefixe si pas trouvée.
-
getFlatOptions
public Properties getFlatOptions(boolean replaceInner)
Surcharge de la methode pour que les options commencant par le prefix soit modifiee pour qu'elle est la meme cle sans le prefix. Le but est de garder les autres options et si une option avait le meme nom qu'elle soit effacee par celle dont on a supprime le prefix- Overrides:
getFlatOptionsin classApplicationConfig- Parameters:
replaceInner- le prefix à remplacer- Returns:
- les options commencant par le prefix soit modifiee pour qu'elle est la meme cle sans le prefix. Le but est de garder les autres options et si une option avait le meme nom qu'elle soit effacee par celle dont on a supprime le prefix
-
getOptionStartsWith
public Properties getOptionStartsWith(String prefix)
Surcharge pour recupere les valeurs commencant par le prefix demande en plus du prefix 'sub'. Les options sont ensuite fusionnee pour permettre aussi les valeurs par defaut- Overrides:
getOptionStartsWithin classApplicationConfig- Parameters:
prefix- prefix to use- Returns:
- les valeurs commençant par le prefix demandé en plus du prefix 'sub'.
-
parse
public ApplicationConfig parse(String... args) throws ArgumentsParserException
Description copied from class:ApplicationConfigParse option and call set necessary method, read jvm, env variable, Load configuration file and prepare Action.- Overrides:
parsein classApplicationConfig- Parameters:
args- argument as main(String[] args)- Returns:
- ApplicationConfig instance
- Throws:
ArgumentsParserException- if parsing failed
-
-