Package de.mhus.lib.core.config
Class DirectoryToConfigWrapper
- java.lang.Object
-
- de.mhus.lib.core.MLog
-
- de.mhus.lib.core.lang.MObject
-
- de.mhus.lib.core.AbstractProperties
-
- de.mhus.lib.core.directory.ResourceNode<W>
-
- de.mhus.lib.core.directory.WritableResourceNode<IConfig>
-
- de.mhus.lib.core.config.IConfig
-
- de.mhus.lib.core.config.DirectoryToConfigWrapper
-
- All Implemented Interfaces:
ILog,IProperties,IReadProperties,MNlsProvider,Nls,Serializable,Iterable<Map.Entry<String,Object>>,Map<String,Object>
public class DirectoryToConfigWrapper extends IConfig
- See Also:
- Serialized Form
-
-
Field Summary
-
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 DirectoryToConfigWrapper(WritableResourceNode<IConfig> node)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()IConfigcreateConfig(String key)Create a new config and append it at the end of the list.booleanequals(Object obj)booleangetBoolean(String name, boolean def)CalendargetCalendar(String name)DategetDate(String name)doublegetDouble(String name, double def)StringgetExtracted(String key)Returns a compiled and executed string.StringgetExtracted(String key, String def)floatgetFloat(String name, float def)InputStreamgetInputStream(String key)Return the input stream of a content resource.intgetInt(String name, int def)longgetLong(String name, long def)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.NumbergetNumber(String name, Number def)ResourceNode<?>getParent()return the parent config if possible.ObjectgetProperty(String name)Overwrite this function to provide values in string format.Collection<String>getPropertyKeys()Return all existing keys.Collection<String>getRenditions()Returns a list of available renditions.StringgetString(String name, String def)URLgetUrl()inthashCode()booleanisEditable()Overwrite this function and return true if the property set can be edited.booleanisProperty(String name)Return true if the property exists.Iterator<Map.Entry<String,Object>>iterator()Set<String>keys()intmoveConfig(IConfig config, int newPos)Move the position of the configuration in the hole set of configurations.voidremoveConfig(IConfig config)Remove a config element from the set.voidremoveProperty(String key)Remove the property field in the list of properties.voidsetBoolean(String name, boolean value)voidsetCalendar(String name, Calendar value)voidsetDate(String name, Date value)voidsetDouble(String name, double value)voidsetFloat(String name, float value)voidsetInt(String name, int value)voidsetLong(String name, long value)voidsetNumber(String name, Number value)voidsetProperty(String key, Object value)Overwrite this function to allow changes in properties.voidsetString(String name, String value)StringtoString()-
Methods inherited from class de.mhus.lib.core.config.IConfig
getRenditionProperties, hasContent, isValid
-
Methods inherited from class de.mhus.lib.core.directory.ResourceNode
containsValue, dump, entrySet, getExtracted, getInputStream, getNodeByPath, getRenditionProperties, size, values
-
Methods inherited from class de.mhus.lib.core.AbstractProperties
containsKey, get, getBoolean, getFormatted, getString, isEmpty, keySet, put, putAll, putReadProperties, remove, toMap
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, 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, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
DirectoryToConfigWrapper
public DirectoryToConfigWrapper(WritableResourceNode<IConfig> node)
-
-
Method Detail
-
getProperty
public Object 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.
-
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
-
getString
public String getString(String name, String def)
- Specified by:
getStringin interfaceIReadProperties- Overrides:
getStringin classAbstractProperties
-
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
-
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
-
getBoolean
public boolean getBoolean(String name, boolean def)
- Specified by:
getBooleanin interfaceIReadProperties- Overrides:
getBooleanin classAbstractProperties
-
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
-
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
-
getInt
public int getInt(String name, int def)
- Specified by:
getIntin interfaceIReadProperties- Overrides:
getIntin classAbstractProperties
-
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
-
setString
public void setString(String name, String value)
- Specified by:
setStringin interfaceIProperties- Overrides:
setStringin classWritableResourceNode<IConfig>
-
hashCode
public int hashCode()
-
getLong
public long getLong(String name, long def)
- Specified by:
getLongin interfaceIReadProperties- Overrides:
getLongin classAbstractProperties
-
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
-
getName
public String getName() throws de.mhus.lib.errors.MException
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
- Throws:
de.mhus.lib.errors.MException
-
getFloat
public float getFloat(String name, float def)
- Specified by:
getFloatin interfaceIReadProperties- Overrides:
getFloatin classAbstractProperties
-
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
-
getExtracted
public String getExtracted(String key)
Description copied from class:ResourceNodeReturns a compiled and executed string. The string is compiled with StringCompiler and is cached. Example is "this is the value of another $anothername,default$" or with the prefix "root.": "This is a root attribute $root.name$ User the "../" prefix to go one back ...- Overrides:
getExtractedin classResourceNode<IConfig>- Returns:
- extracted values
- See Also:
StringCompiler
-
getDouble
public double getDouble(String name, double def)
- Specified by:
getDoublein interfaceIReadProperties- Overrides:
getDoublein classAbstractProperties
-
getCalendar
public Calendar getCalendar(String name) throws de.mhus.lib.errors.MException
- Specified by:
getCalendarin interfaceIReadProperties- Overrides:
getCalendarin classAbstractProperties- Throws:
de.mhus.lib.errors.MException
-
getExtracted
public String getExtracted(String key, String def)
- Overrides:
getExtractedin classResourceNode<IConfig>
-
getDate
public Date getDate(String name)
- Specified by:
getDatein interfaceIReadProperties- Overrides:
getDatein classAbstractProperties
-
getParent
public ResourceNode<?> getParent()
Description copied from class:ResourceNodereturn the parent config if possible.- Specified by:
getParentin classResourceNode<IConfig>- Returns:
- parent node
-
keys
public Set<String> keys()
- Specified by:
keysin interfaceIReadProperties- Overrides:
keysin classResourceNode<IConfig>- Returns:
- the keys
-
setInt
public void setInt(String name, int value)
- Specified by:
setIntin interfaceIProperties- Overrides:
setIntin classAbstractProperties
-
setLong
public void setLong(String name, long value)
- Specified by:
setLongin interfaceIProperties- Overrides:
setLongin classAbstractProperties
-
setDouble
public void setDouble(String name, double value)
- Specified by:
setDoublein interfaceIProperties- Overrides:
setDoublein classAbstractProperties
-
setFloat
public void setFloat(String name, float value)
- Specified by:
setFloatin interfaceIProperties- Overrides:
setFloatin classAbstractProperties
-
setBoolean
public void setBoolean(String name, boolean value)
- Specified by:
setBooleanin interfaceIProperties- Overrides:
setBooleanin classAbstractProperties
-
setCalendar
public void setCalendar(String name, Calendar value)
- Specified by:
setCalendarin interfaceIProperties- Overrides:
setCalendarin classAbstractProperties
-
equals
public boolean equals(Object obj)
-
setDate
public void setDate(String name, Date value)
- Specified by:
setDatein interfaceIProperties- Overrides:
setDatein classAbstractProperties
-
setNumber
public void setNumber(String name, Number value)
- Specified by:
setNumberin interfaceIProperties- Overrides:
setNumberin classAbstractProperties
-
getNumber
public Number getNumber(String name, Number def)
- Specified by:
getNumberin interfaceIReadProperties- Overrides:
getNumberin classAbstractProperties
-
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
-
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
-
getUrl
public URL getUrl()
- Specified by:
getUrlin classResourceNode<IConfig>
-
getRenditions
public Collection<String> getRenditions()
Description copied from class:ResourceNodeReturns a list of available renditions. Will not return the default rendition.- Overrides:
getRenditionsin classIConfig- Returns:
- The list or null if hasContent() is false
-
clear
public void clear()
-
-