Package de.mhus.lib.core.config
Class PropertiesConfig
-
- All Implemented Interfaces:
IFlatConfig,ILog,IProperties,IReadProperties,MNlsProvider,Nls,Serializable,Iterable<Map.Entry<String,Object>>,Map<String,Object>
- Direct Known Subclasses:
DirConfig,NodeConfig,PropertiesConfigFile
public class PropertiesConfig extends IConfig implements IFlatConfig
Load the configuration from a properties file. The implementation do not support inner configurations.- Author:
- mhu
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanchangedprotected Stringnameprotected Propertiesproperties-
Fields inherited from class de.mhus.lib.core.directory.WritableResourceNode
MOVE_DOWN, MOVE_FIRST, MOVE_LAST, MOVE_UP
-
Fields inherited from class de.mhus.lib.core.directory.ResourceNode
compiledCache, compiler
-
-
Constructor Summary
Constructors Constructor Description PropertiesConfig()PropertiesConfig(String fill)PropertiesConfig(Properties config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()voidconfigRemoved()IConfigcreateConfig(String key)Create a new config and append it at the end of the list.InputStreamgetInputStream(String key)Return the input stream of a content resource.StringgetName()Return a name of this config element could also be null.IConfiggetNode(String key)Returns a inner configuration by the name.List<String>getNodeKeys()Return all possible, existing inner configuration names.List<IConfig>getNodes()Return all inner configurations ignoring the name.List<IConfig>getNodes(String key)Return all inner configurations by the given name.IConfiggetParent()return the parent config if possible.StringgetProperty(String name)Overwrite this function to provide values in string format.List<String>getPropertyKeys()Return all existing keys.URLgetUrl()booleanisConfigChanged()booleanisEditable()Overwrite this function and return true if the property set can be edited.booleanisProperty(String name)Return true if the property exists.intmoveConfig(IConfig config, int newPos)Move the position of the configuration in the hole set of configurations.voidreadConfig(Reader file)voidremoveConfig(IConfig config)Remove a config element from the set.voidremoveProperty(String key)Remove the property field in the list of properties.voidsetProperty(String key, Object value)Overwrite this function to allow changes in properties.voidwriteConfig(Writer os)-
Methods inherited from class de.mhus.lib.core.config.IConfig
getRenditionProperties, getRenditions, hasContent, isValid
-
Methods inherited from class de.mhus.lib.core.directory.WritableResourceNode
setString
-
Methods inherited from class de.mhus.lib.core.directory.ResourceNode
containsValue, dump, entrySet, getExtracted, getExtracted, getExtracted, getInputStream, getNodeByPath, getRenditionProperties, keys, size, values
-
Methods inherited from class de.mhus.lib.core.AbstractProperties
containsKey, get, getBoolean, getBoolean, getCalendar, getDate, getDouble, getFloat, getFormatted, getInt, getLong, getNumber, getString, getString, isEmpty, iterator, keySet, put, putAll, putReadProperties, remove, setBoolean, setCalendar, setDate, setDouble, setFloat, setInt, setLong, setNumber, toMap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Field Detail
-
properties
protected Properties properties
-
changed
protected boolean changed
-
name
protected String name
-
-
Constructor Detail
-
PropertiesConfig
public PropertiesConfig()
-
PropertiesConfig
public PropertiesConfig(Properties config)
-
PropertiesConfig
public PropertiesConfig(String fill)
-
-
Method Detail
-
writeConfig
public void writeConfig(Writer os) throws IOException
- Throws:
IOException
-
readConfig
public void readConfig(Reader file) throws IOException
- Throws:
IOException
-
configRemoved
public void configRemoved()
-
getNode
public IConfig getNode(String key)
Description copied from class:ResourceNodeReturns a inner configuration by the name. Inner configurations are not unique. If more then one configurations exists it will return the first one. if no configuration exists it returns null.- Specified by:
getNodein classResourceNode<IConfig>- Returns:
- the node with the name
-
getNodes
public List<IConfig> getNodes(String key)
Description copied from class:ResourceNodeReturn all inner configurations by the given name. The order is like in the configuration file. This never returns null.- Specified by:
getNodesin classResourceNode<IConfig>- Returns:
- all nodes with the name
-
getNodes
public List<IConfig> getNodes()
Description copied from class:ResourceNodeReturn all inner configurations ignoring the name. The order is like in the configuration file. This never returns null.- Specified by:
getNodesin classResourceNode<IConfig>- Returns:
- all nodes
-
getNodeKeys
public List<String> getNodeKeys()
Description copied from class:ResourceNodeReturn all possible, existing inner configuration names.- Specified by:
getNodeKeysin classResourceNode<IConfig>- Returns:
- keys from nodes
-
getPropertyKeys
public List<String> getPropertyKeys()
Description copied from class:ResourceNodeReturn all existing keys. A property key is unique.- Specified by:
getPropertyKeysin classResourceNode<IConfig>- Returns:
- all keys
-
getProperty
public String getProperty(String name)
Description copied from class:AbstractPropertiesOverwrite this function to provide values in string format.- Specified by:
getPropertyin interfaceIReadProperties- Specified by:
getPropertyin classAbstractProperties- Returns:
- null if the property not exists or the property value.
-
isProperty
public boolean isProperty(String name)
Description copied from class:AbstractPropertiesReturn true if the property exists.- Specified by:
isPropertyin interfaceIReadProperties- Specified by:
isPropertyin classAbstractProperties- Returns:
- if exists
-
removeProperty
public void removeProperty(String key)
Description copied from class:AbstractPropertiesRemove the property field in the list of properties.- Specified by:
removePropertyin interfaceIProperties- Specified by:
removePropertyin classAbstractProperties
-
setProperty
public void setProperty(String key, Object value)
Description copied from class:AbstractPropertiesOverwrite this function to allow changes in properties.- Specified by:
setPropertyin classAbstractProperties
-
isConfigChanged
public boolean isConfigChanged()
-
getName
public String getName()
Description copied from class:ResourceNodeReturn a name of this config element could also be null. The name most time is the name of a sub config.- Specified by:
getNamein classResourceNode<IConfig>- Returns:
- node of this node
-
createConfig
public IConfig createConfig(String key) throws de.mhus.lib.errors.MException
Description copied from class:WritableResourceNodeCreate a new config and append it at the end of the list. After creation the element is already at the end of the list.- Specified by:
createConfigin classWritableResourceNode<IConfig>- Returns:
- new config node
- Throws:
de.mhus.lib.errors.MException- if editing is not possible
-
moveConfig
public int moveConfig(IConfig config, int newPos) throws de.mhus.lib.errors.MException
Description copied from class:WritableResourceNodeMove the position of the configuration in the hole set of configurations. If the config is not part of the set it will throw an exception. The first position is 0.- Specified by:
moveConfigin classWritableResourceNode<IConfig>- Parameters:
config- The config object which you want to movenewPos- Absolute new position or one of the move operators MOVE_UP, MOVE_DOWN, MOVE_FIRST, MOVE_LAST- Returns:
- The new pos of the config
- Throws:
de.mhus.lib.errors.MException- if editing is not possible or the position is out of range
-
removeConfig
public void removeConfig(IConfig config) throws de.mhus.lib.errors.MException
Description copied from class:WritableResourceNodeRemove a config element from the set. If the config element is not part of the set it will not throw an error.- Specified by:
removeConfigin classWritableResourceNode<IConfig>- Parameters:
config- The config object which should be removed.- Throws:
de.mhus.lib.errors.MException- if editing is not possible
-
isEditable
public boolean isEditable()
Description copied from class:AbstractPropertiesOverwrite this function and return true if the property set can be edited.- Specified by:
isEditablein interfaceIProperties- Specified by:
isEditablein classAbstractProperties- Returns:
- if is editable
-
getParent
public IConfig getParent()
Description copied from class:ResourceNodereturn the parent config if possible.- Specified by:
getParentin classResourceNode<IConfig>- Returns:
- parent node
-
getInputStream
public InputStream getInputStream(String key)
Description copied from class:ResourceNodeReturn the input stream of a content resource.- Specified by:
getInputStreamin classResourceNode<IConfig>- Parameters:
key- Name of a rendition or null for the default content- Returns:
- input stream
-
getUrl
public URL getUrl()
- Specified by:
getUrlin classResourceNode<IConfig>
-
-