Class ResourceMetadata
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<java.lang.String,java.lang.Object>
-
- org.apache.sling.api.resource.ResourceMetadata
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map<java.lang.String,java.lang.Object>
public class ResourceMetadata extends java.util.HashMap<java.lang.String,java.lang.Object>TheResourceMetadatainterface defines the API for the metadata of a SlingResource. 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.resolutionPathproperty 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 beString.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCHARACTER_ENCODINGThe 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 java.lang.StringCONTENT_LENGTHThe name of the optional property providing the content length of the resource if the resource is streamable (value is "sling.contentLength").static java.lang.StringCONTENT_TYPEThe name of the optional property providing the content type of the resource if the resource is streamable (value is "sling.contentType").static java.lang.StringCREATION_TIMEReturns the creation time of this resource in the repository in milliseconds (value is "sling.creationTime").static java.lang.StringINTERNAL_CONTINUE_RESOLVINGDeprecated.This flag is not supported anymore when implementing the SPI basedorg.apache.sling.spi.resource.provider.ResourceProviderstatic java.lang.StringMODIFICATION_TIMEReturns the last modification time of this resource in the repository in milliseconds (value is "sling.modificationTime").static java.lang.StringPARAMETER_MAPReturns a map containing parameters added to path after semicolon.static java.lang.StringRESOLUTION_PATHThe 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 java.lang.StringRESOLUTION_PATH_INFOThe 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 Constructor Description ResourceMetadata()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()java.lang.Objectclone()@NotNull java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>>entrySet()@Nullable java.lang.StringgetCharacterEncoding()longgetContentLength()@Nullable java.lang.StringgetContentType()longgetCreationTime()longgetModificationTime()@Nullable java.util.Map<java.lang.String,java.lang.String>getParameterMap()@Nullable java.lang.StringgetResolutionPath()@Nullable java.lang.StringgetResolutionPathInfo()@NotNull java.util.Set<java.lang.String>keySet()voidlock()Make this object read-only.java.lang.Objectput(@NotNull java.lang.String key, java.lang.Object value)voidputAll(@NotNull java.util.Map<? extends java.lang.String,? extends java.lang.Object> m)java.lang.Objectremove(@NotNull java.lang.Object key)voidsetCharacterEncoding(java.lang.String encoding)voidsetContentLength(long contentLength)voidsetContentType(java.lang.String contentType)voidsetCreationTime(long creationTime)Sets theCREATION_TIMEproperty tocreationTimeif not negative.voidsetModificationTime(long modificationTime)Sets theMODIFICATION_TIMEproperty tomodificationTimeif not negative.voidsetParameterMap(java.util.Map<java.lang.String,java.lang.String> parameterMap)voidsetResolutionPath(java.lang.String resolutionPath)voidsetResolutionPathInfo(java.lang.String resolutionPathInfo)@NotNull java.util.Collection<java.lang.Object>values()
-
-
-
Field Detail
-
RESOLUTION_PATH
public static final java.lang.String 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:
- Constant Field Values
-
RESOLUTION_PATH_INFO
public static final java.lang.String 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:
- Constant Field Values
-
CONTENT_TYPE
public static final java.lang.String 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:
- Constant Field Values
-
CONTENT_LENGTH
public static final java.lang.String 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:
- Constant Field Values
-
CHARACTER_ENCODING
public static final java.lang.String 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:
- Constant Field Values
-
CREATION_TIME
public static final java.lang.String 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:
- Constant Field Values
-
MODIFICATION_TIME
public static final java.lang.String 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:
- Constant Field Values
-
INTERNAL_CONTINUE_RESOLVING
@Deprecated public static final java.lang.String 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:
- Constant Field Values
-
PARAMETER_MAP
public static final java.lang.String 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:
- Constant Field Values
-
-
Method Detail
-
setCharacterEncoding
public void setCharacterEncoding(java.lang.String encoding)
- Parameters:
encoding- The encoding
-
getCharacterEncoding
@Nullable public @Nullable java.lang.String getCharacterEncoding()
Returns theCHARACTER_ENCODINGproperty if notnulland aStringinstance. Otherwisenullis returned.- Returns:
- The character encoding
-
setContentType
public void setContentType(java.lang.String contentType)
- Parameters:
contentType- The content type
-
getContentType
@Nullable public @Nullable java.lang.String 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
public void setResolutionPath(java.lang.String resolutionPath)
- Parameters:
resolutionPath- The resolution path
-
getResolutionPath
@Nullable public @Nullable java.lang.String getResolutionPath()
- Returns:
- The resolution path
-
setResolutionPathInfo
public void setResolutionPathInfo(java.lang.String resolutionPathInfo)
- Parameters:
resolutionPathInfo- The resolution path info
-
getResolutionPathInfo
@Nullable public @Nullable java.lang.String getResolutionPathInfo()
Returns theRESOLUTION_PATH_INFOproperty if notnulland aStringinstance. Otherwisenullis returned.- Returns:
- The resolution path info
-
setParameterMap
public void setParameterMap(java.util.Map<java.lang.String,java.lang.String> parameterMap)
- Parameters:
parameterMap- The parameter map
-
getParameterMap
@Nullable public @Nullable java.util.Map<java.lang.String,java.lang.String> 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()
- Specified by:
clearin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
clearin classjava.util.HashMap<java.lang.String,java.lang.Object>
-
put
public java.lang.Object put(@NotNull @NotNull java.lang.String key, java.lang.Object value)- Specified by:
putin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
putin classjava.util.HashMap<java.lang.String,java.lang.Object>
-
putAll
public void putAll(@NotNull @NotNull java.util.Map<? extends java.lang.String,? extends java.lang.Object> m)- Specified by:
putAllin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
putAllin classjava.util.HashMap<java.lang.String,java.lang.Object>
-
remove
public java.lang.Object remove(@NotNull @NotNull java.lang.Object key)- Specified by:
removein interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
removein classjava.util.HashMap<java.lang.String,java.lang.Object>
-
clone
public java.lang.Object clone()
- Overrides:
clonein classjava.util.HashMap<java.lang.String,java.lang.Object>
-
entrySet
@NotNull public @NotNull java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
- Specified by:
entrySetin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
entrySetin classjava.util.HashMap<java.lang.String,java.lang.Object>
-
keySet
@NotNull public @NotNull java.util.Set<java.lang.String> keySet()
- Specified by:
keySetin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
keySetin classjava.util.HashMap<java.lang.String,java.lang.Object>
-
values
@NotNull public @NotNull java.util.Collection<java.lang.Object> values()
- Specified by:
valuesin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
valuesin classjava.util.HashMap<java.lang.String,java.lang.Object>
-
-