Package de.mhus.lib.core.directory.fs
Class FileResource
- 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<FileResource>
-
- de.mhus.lib.core.directory.fs.FileResource
-
- All Implemented Interfaces:
ILog,IProperties,IReadProperties,MNlsProvider,Nls,Serializable,Iterable<Map.Entry<String,Object>>,Map<String,Object>
- Direct Known Subclasses:
FileResourceRoot
public class FileResource extends ResourceNode<FileResource>
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFileResource.KEYSstatic classFileResource.TYPE
-
Field Summary
Fields Modifier and Type Field Description static longUNKNOWN_LENGTH-
Fields inherited from class de.mhus.lib.core.directory.ResourceNode
compiledCache, compiler
-
-
Constructor Summary
Constructors Constructor Description FileResource(FileResourceRoot root, FileResource parent, File file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()InputStreamgetInputStream(String key)Return the input stream of a content resource.StringgetName()Return a name of this config element could also be null.FileResourcegetNode(String key)Returns a inner configuration by the name.Collection<String>getNodeKeys()Return all possible, existing inner configuration names.Collection<FileResource>getNodes()Return all inner configurations ignoring the name.Collection<FileResource>getNodes(String key)Return all inner configurations by the given name.FileResourcegetParent()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.IPropertiesgetRenditionProperties(String rendition)Returns a set of properties to define the rendition.Collection<String>getRenditions()Returns a list of available renditions.URLgetUrl()booleanhasContent()booleanisEditable()Overwrite this function and return true if the property set can be edited.booleanisProperty(String name)Return true if the property exists.booleanisValid()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.-
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, setString, 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
-
UNKNOWN_LENGTH
public static final long UNKNOWN_LENGTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileResource
public FileResource(FileResourceRoot root, FileResource parent, File file)
-
-
Method Detail
-
getPropertyKeys
public Collection<String> getPropertyKeys()
Description copied from class:ResourceNodeReturn all existing keys. A property key is unique.- Specified by:
getPropertyKeysin classResourceNode<FileResource>- Returns:
- all keys
-
getNode
public FileResource 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<FileResource>- Returns:
- the node with the name
-
getNodes
public Collection<FileResource> 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<FileResource>- Returns:
- all nodes
-
getNodes
public Collection<FileResource> 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<FileResource>- 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<FileResource>- 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<FileResource>- Returns:
- node of this node
- Throws:
de.mhus.lib.errors.MException
-
getInputStream
public InputStream getInputStream(String key)
Description copied from class:ResourceNodeReturn the input stream of a content resource.- Specified by:
getInputStreamin classResourceNode<FileResource>- Parameters:
key- Name of a rendition or null for the default content- Returns:
- input stream
-
getParent
public FileResource getParent()
Description copied from class:ResourceNodereturn the parent config if possible.- Specified by:
getParentin classResourceNode<FileResource>- Returns:
- parent node
-
getUrl
public URL getUrl()
- Specified by:
getUrlin classResourceNode<FileResource>
-
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.
-
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
-
isValid
public boolean isValid()
- Specified by:
isValidin classResourceNode<FileResource>
-
hasContent
public boolean hasContent()
- Specified by:
hasContentin classResourceNode<FileResource>
-
getRenditions
public Collection<String> getRenditions()
Description copied from class:ResourceNodeReturns a list of available renditions. Will not return the default rendition.- Specified by:
getRenditionsin classResourceNode<FileResource>- Returns:
- The list or null if hasContent() is false
-
clear
public void clear()
-
getRenditionProperties
public IProperties getRenditionProperties(String rendition)
Description copied from class:ResourceNodeReturns a set of properties to define the rendition.- Specified by:
getRenditionPropertiesin classResourceNode<FileResource>- Returns:
- properties
-
-