Class ResourceMetadata
- All Implemented Interfaces:
Serializable,Cloneable,Map<String,Object>
ResourceMetadata interface defines the API for the
metadata of a Sling Resource. Essentially the resource's metadata is
just a map of objects indexed by string keys.
The actual contents of the meta data map is implementation specific with the
exception of the sling.resolutionPath property which
must be provided by all implementations and contain the part of the request
URI used to resolve the resource. The type of this property value is defined
to be String.
Note, that the prefix sling. to key names is reserved for the
Sling implementation.
Once a resource is returned by the ResourceResolver, the resource
metadata is made read-only and therefore can't be changed by client code!
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the optional property providing the character encoding of the resource if the resource is streamable and contains character data (value is "sling.characterEncoding").static final StringThe name of the optional property providing the content length of the resource if the resource is streamable (value is "sling.contentLength").static final StringThe name of the optional property providing the content type of the resource if the resource is streamable (value is "sling.contentType").static final StringReturns the creation time of this resource in the repository in milliseconds (value is "sling.creationTime").static final StringDeprecated.static final StringReturns the last modification time of this resource in the repository in milliseconds (value is "sling.modificationTime").static final StringReturns a map containing parameters added to path after semicolon.static final StringThe name of the required property providing the part of the request URI which was used to the resolve the resource to which the meta data instance belongs (value is "sling.resolutionPath").static final StringThe name of the required property providing the part of the request URI which was not used to the resolve the resource to which the meta data instance belongs (value is "sling.resolutionPathInfo"). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()clone()entrySet()@Nullable Stringlong@Nullable Stringlonglong@Nullable String@Nullable Stringprotected voidinternalPut(@NotNull String key, Object value) keySet()voidlock()Make this object read-only.voidvoidsetCharacterEncoding(String encoding) voidsetContentLength(long contentLength) voidsetContentType(String contentType) voidsetCreationTime(long creationTime) Sets theCREATION_TIMEproperty tocreationTimeif not negative.voidsetModificationTime(long modificationTime) Sets theMODIFICATION_TIMEproperty tomodificationTimeif not negative.voidsetParameterMap(Map<String, String> parameterMap) voidsetResolutionPath(String resolutionPath) voidsetResolutionPathInfo(String resolutionPathInfo) @NotNull Collection<Object>values()Methods inherited from class java.util.HashMap
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, forEach, get, getOrDefault, isEmpty, merge, putIfAbsent, remove, replace, replace, replaceAll, sizeMethods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Field Details
-
RESOLUTION_PATH
The name of the required property providing the part of the request URI which was used to the resolve the resource to which the meta data instance belongs (value is "sling.resolutionPath").- See Also:
-
RESOLUTION_PATH_INFO
The name of the required property providing the part of the request URI which was not used to the resolve the resource to which the meta data instance belongs (value is "sling.resolutionPathInfo"). The value of this property concatenated to the value of thesling.resolutionPathproperty returns the original request URI leading to the resource.This property is optional. If missing, it should be assumed equal to an empty string.
- Since:
- 2.0.4 (Sling API Bundle 2.0.4)
- See Also:
-
CONTENT_TYPE
The name of the optional property providing the content type of the resource if the resource is streamable (value is "sling.contentType"). This property may be missing if the resource is not streamable or if the content type is not known.- See Also:
-
CONTENT_LENGTH
The name of the optional property providing the content length of the resource if the resource is streamable (value is "sling.contentLength"). This property may be missing if the resource is not streamable or if the content length is not known.Note, that unlike the other properties, this property may be set only after the resource has successfully been adapted to an
InputStreamfor performance reasons.- See Also:
-
CHARACTER_ENCODING
The name of the optional property providing the character encoding of the resource if the resource is streamable and contains character data (value is "sling.characterEncoding"). This property may be missing if the resource is not streamable or if the character encoding is not known.- See Also:
-
CREATION_TIME
Returns the creation time of this resource in the repository in milliseconds (value is "sling.creationTime"). The type of this property isjava.lang.Long. The property may be missing if the resource is not streamable or if the creation time is not known.- See Also:
-
MODIFICATION_TIME
Returns the last modification time of this resource in the repository in milliseconds (value is "sling.modificationTime"). The type of this property isjava.lang.Long. The property may be missing if the resource is not streamable or if the last modification time is not known.- See Also:
-
INTERNAL_CONTINUE_RESOLVING
Deprecated.This flag is not supported anymore when implementing the SPI basedorg.apache.sling.spi.resource.provider.ResourceProviderReturns whether the resource resolver should continue to search for a resource. A resource provider can set this flag to indicate that the resource resolver should search for a provider with a lower priority. If it finds a resource using such a provider, that resource is returned instead. If none is found this resource is returned. This flag should never be manipulated by application code! The value of this property has no meaning, the resource resolver just checks whether this flag is set or not.- Since:
- 2.2 (Sling API Bundle 2.2.0)
- See Also:
-
PARAMETER_MAP
Returns a map containing parameters added to path after semicolon. For instance, map for path/content/test;v='1.2.3'.htmlwill contain one entry keyvand value1.2.3.- See Also:
-
-
Constructor Details
-
ResourceMetadata
public ResourceMetadata()
-
-
Method Details
-
setCharacterEncoding
- Parameters:
encoding- The encoding
-
getCharacterEncoding
Returns theCHARACTER_ENCODINGproperty if notnulland aStringinstance. Otherwisenullis returned.- Returns:
- The character encoding
-
setContentType
- Parameters:
contentType- The content type
-
getContentType
- Returns:
- The content type
-
setContentLength
public void setContentLength(long contentLength) - Parameters:
contentLength- The content length
-
getContentLength
public long getContentLength()- Returns:
- The content length
-
setCreationTime
public void setCreationTime(long creationTime) Sets theCREATION_TIMEproperty tocreationTimeif not negative.- Parameters:
creationTime- The creation time
-
getCreationTime
public long getCreationTime()- Returns:
- The creation time
-
setModificationTime
public void setModificationTime(long modificationTime) Sets theMODIFICATION_TIMEproperty tomodificationTimeif not negative.- Parameters:
modificationTime- The modification time
-
getModificationTime
public long getModificationTime()- Returns:
- The modification time
-
setResolutionPath
- Parameters:
resolutionPath- The resolution path
-
getResolutionPath
- Returns:
- The resolution path
-
setResolutionPathInfo
- Parameters:
resolutionPathInfo- The resolution path info
-
getResolutionPathInfo
Returns theRESOLUTION_PATH_INFOproperty if notnulland aStringinstance. Otherwisenullis returned.- Returns:
- The resolution path info
-
setParameterMap
- Parameters:
parameterMap- The parameter map
-
getParameterMap
- Returns:
- The parameter map
-
lock
public void lock()Make this object read-only. All method calls trying to modify this object result in an exception!- Since:
- 2.3 (Sling API Bundle 2.4.0)
-
clear
public void clear() -
put
-
putAll
-
remove
-
internalPut
-
clone
-
entrySet
-
keySet
-
values
-
org.apache.sling.spi.resource.provider.ResourceProvider