Package de.mhus.lib.core.directory
Class ResourceNode<T extends ResourceNode<?>>
- 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<T>
-
- Type Parameters:
T-
- All Implemented Interfaces:
ILog,IProperties,IReadProperties,MNlsProvider,Nls,Serializable,Iterable<Map.Entry<String,Object>>,Map<String,Object>
- Direct Known Subclasses:
EmptyResourceNode,FileResource,WritableResourceNode
public abstract class ResourceNode<T extends ResourceNode<?>> extends AbstractProperties
This interface represent a generic Directory Node. Nodes are sets of definitions. The definitions can be bound together to a inner Nodes.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected HashMap<String,CompiledString>compiledCacheprotected de.mhus.lib.core.directory.ResourceNode.ConfigStringCompilercompiler
-
Constructor Summary
Constructors Constructor Description ResourceNode()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancontainsValue(Object value)Stringdump()Set<Map.Entry<String,Object>>entrySet()StringgetExtracted(String key)Returns a compiled and executed string.StringgetExtracted(String key, String def)protected StringgetExtracted(String key, String def, int level)InputStreamgetInputStream()Return the default content input stream.abstract InputStreamgetInputStream(String rendition)Return the input stream of a content resource.abstract StringgetName()Return a name of this config element could also be null.abstract TgetNode(String key)Returns a inner configuration by the name.TgetNodeByPath(String path)abstract Collection<String>getNodeKeys()Return all possible, existing inner configuration names.abstract Collection<T>getNodes()Return all inner configurations ignoring the name.abstract Collection<T>getNodes(String key)Return all inner configurations by the given name.abstract ResourceNode<?>getParent()return the parent config if possible.abstract Collection<String>getPropertyKeys()Return all existing keys.IPropertiesgetRenditionProperties()abstract IPropertiesgetRenditionProperties(String rendition)Returns a set of properties to define the rendition.abstract Collection<String>getRenditions()Returns a list of available renditions.abstract URLgetUrl()abstract booleanhasContent()abstract booleanisValid()Set<String>keys()intsize()Collection<Object>values()-
Methods inherited from class de.mhus.lib.core.AbstractProperties
containsKey, get, getBoolean, getBoolean, getCalendar, getDate, getDouble, getFloat, getFormatted, getInt, getLong, getNumber, getProperty, getString, getString, isEditable, isEmpty, isProperty, iterator, keySet, put, putAll, putReadProperties, remove, removeProperty, setBoolean, setCalendar, setDate, setDouble, setFloat, setInt, setLong, setNumber, setProperty, setString, toMap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.mhus.lib.core.IProperties
clear
-
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
-
compiler
protected de.mhus.lib.core.directory.ResourceNode.ConfigStringCompiler compiler
-
compiledCache
protected HashMap<String,CompiledString> compiledCache
-
-
Method Detail
-
getPropertyKeys
public abstract Collection<String> getPropertyKeys()
Return all existing keys. A property key is unique.- Returns:
- all keys
-
getNode
public abstract T getNode(String key)
Returns 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.- Parameters:
key-- Returns:
- the node with the name
-
getNodes
public abstract Collection<T> getNodes()
Return all inner configurations ignoring the name. The order is like in the configuration file. This never returns null.- Returns:
- all nodes
-
getNodes
public abstract Collection<T> getNodes(String key)
Return all inner configurations by the given name. The order is like in the configuration file. This never returns null.- Parameters:
key-- Returns:
- all nodes with the name
-
getNodeKeys
public abstract Collection<String> getNodeKeys()
Return all possible, existing inner configuration names.- Returns:
- keys from nodes
-
getName
public abstract String getName() throws de.mhus.lib.errors.MException
Return a name of this config element could also be null. The name most time is the name of a sub config.- Returns:
- node of this node
- Throws:
de.mhus.lib.errors.MException
-
getInputStream
public InputStream getInputStream()
Return the default content input stream.- Returns:
- input stream
-
getInputStream
public abstract InputStream getInputStream(String rendition)
Return the input stream of a content resource.- Parameters:
rendition- Name of a rendition or null for the default content- Returns:
- input stream
-
getRenditions
public abstract Collection<String> getRenditions()
Returns a list of available renditions. Will not return the default rendition.- Returns:
- The list or null if hasContent() is false
-
getRenditionProperties
public IProperties getRenditionProperties()
-
getRenditionProperties
public abstract IProperties getRenditionProperties(String rendition)
Returns a set of properties to define the rendition.- Parameters:
rendition-- Returns:
- properties
-
getExtracted
public String getExtracted(String key)
Returns 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 ...- Parameters:
key-- Returns:
- extracted values
- See Also:
StringCompiler
-
getParent
public abstract ResourceNode<?> getParent()
return the parent config if possible.- Returns:
- parent node
-
keys
public Set<String> keys()
- Specified by:
keysin interfaceIReadProperties- Specified by:
keysin classAbstractProperties- Returns:
- the keys
-
getUrl
public abstract URL getUrl()
-
isValid
public abstract boolean isValid()
-
hasContent
public abstract boolean hasContent()
-
dump
public String dump() throws de.mhus.lib.errors.MException
- Throws:
de.mhus.lib.errors.MException
-
size
public int size()
-
containsValue
public boolean containsValue(Object value)
-
values
public Collection<Object> values()
-
-