Package de.mhus.lib.core.config
Class XmlConfig
-
- All Implemented Interfaces:
ILog,IProperties,IReadProperties,MNlsProvider,Nls,Serializable,Iterable<Map.Entry<String,Object>>,Map<String,Object>
- Direct Known Subclasses:
XmlConfigFile
public class XmlConfig extends IConfig
Implements a configuration loaded from xml structures.- Author:
- mhu
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanchangedprotected Elementelementprotected Stringnameprotected XmlConfigparentstatic StringVALUEUse this special key to access the tag value (without inner tags).-
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()XmlConfigcreateConfig(String name)Create a new config and append it at the end of the list.booleanequals(Object obj)DocumentgetDocument()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.Collection<String>getNodeKeys()Return all possible, existing inner configuration names.Collection<IConfig>getNodes()Return all inner configurations ignoring the name.Collection<IConfig>getNodes(String key)Return all inner configurations by the given name.IConfiggetParent()return the parent config if possible.StringgetProperty(String key)Overwrite this function to provide values in string format.Collection<String>getPropertyKeys()Return all existing keys.URLgetUrl()ElementgetXmlElement()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 name)Remove the property field in the list of properties.voidsetProperty(String key, Object val)Overwrite this function to allow changes in properties.voidwriteConfig(Writer configStream)voidwriteConfig(Writer configStream, boolean intend)-
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, 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, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Field Detail
-
VALUE
public static final String VALUE
Use this special key to access the tag value (without inner tags). This is a special value it will not be listed for keys and can not be removed.- See Also:
- Constant Field Values
-
element
protected Element element
-
changed
protected boolean changed
-
parent
protected XmlConfig parent
-
name
protected String name
-
-
Method Detail
-
getDocument
public Document getDocument()
-
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 Collection<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
-
getNodes
public Collection<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
-
getNodeKeys
public Collection<String> getNodeKeys()
Description copied from class:ResourceNodeReturn all possible, existing inner configuration names.- Specified by:
getNodeKeysin classResourceNode<IConfig>- Returns:
- keys from nodes
-
getPropertyKeys
public Collection<String> getPropertyKeys()
Description copied from class:ResourceNodeReturn all existing keys. A property key is unique.- Specified by:
getPropertyKeysin classResourceNode<IConfig>- Returns:
- all keys
-
removeProperty
public void removeProperty(String name)
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 val)
Description copied from class:AbstractPropertiesOverwrite this function to allow changes in properties.- Specified by:
setPropertyin classAbstractProperties
-
writeConfig
public void writeConfig(Writer configStream, boolean intend) throws Exception
- Throws:
Exception
-
createConfig
public XmlConfig createConfig(String name)
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
-
getProperty
public String getProperty(String key)
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
-
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
-
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
-
getXmlElement
public Element getXmlElement()
-
equals
public boolean equals(Object obj)
-
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>
-
clear
public void clear()
-
-