org.apache.sling.api.resource
Class ResourceMetadata

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,Object>
          extended by org.apache.sling.api.resource.ResourceMetadata
All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>

public class ResourceMetadata
extends HashMap<String,Object>

The 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.

See Also:
Serialized Form

Field Summary
static 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").
static 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").
static 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").
static String CREATION_TIME
          Returns the creation time of this resource in the repository in milliseconds (value is "sling.creationTime").
static String MODIFICATION_TIME
          Returns the last modification time of this resource in the repository in milliseconds (value is "sling.modificationTime").
static 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").
static 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").
 
Constructor Summary
ResourceMetadata()
           
 
Method Summary
 String getCharacterEncoding()
          Returns the CHARACTER_ENCODING property if not null and a String instance.
 long getContentLength()
          Returns the CONTENT_LENGTH property if not null and a long.
 String getContentType()
          Returns the CONTENT_TYPE property if not null and a String instance.
 long getCreationTime()
          Returns the CREATION_TIME property if not null and a long.
 long getModificationTime()
          Returns the MODIFICATION_TIME property if not null and a long.
 String getResolutionPath()
          Returns the RESOLUTION_PATH property if not null and a String instance.
 String getResolutionPathInfo()
          Returns the RESOLUTION_PATH_INFO property if not null and a String instance.
 void setCharacterEncoding(String encoding)
          Sets the CHARACTER_ENCODING property to encoding if not null.
 void setContentLength(long contentLength)
          Sets the CONTENT_LENGTH property to contentType if not null.
 void setContentType(String contentType)
          Sets the CONTENT_TYPE property to contentType if not null.
 void setCreationTime(long creationTime)
          Sets the CREATION_TIME property to creationTime if not negative.
 void setModificationTime(long modificationTime)
          Sets the MODIFICATION_TIME property to modificationTime if not negative.
 void setResolutionPath(String resolutionPath)
          Sets the RESOLUTION_PATH property to resolutionPath if not null.
 void setResolutionPathInfo(String resolutionPathInfo)
          Sets the RESOLUTION_PATH_INFO property to resolutionPathInfo if not null.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

RESOLUTION_PATH

public static final 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 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 the sling.resolutionPath property 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
See Also:
Constant Field Values

CONTENT_TYPE

public static final 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 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 InputStream for performance reasons.

See Also:
Constant Field Values

CHARACTER_ENCODING

public static final 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 String CREATION_TIME
Returns the creation time of this resource in the repository in milliseconds (value is "sling.creationTime"). The type of this property is java.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 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 is java.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
Constructor Detail

ResourceMetadata

public ResourceMetadata()
Method Detail

setCharacterEncoding

public void setCharacterEncoding(String encoding)
Sets the CHARACTER_ENCODING property to encoding if not null.


getCharacterEncoding

public String getCharacterEncoding()
Returns the CHARACTER_ENCODING property if not null and a String instance. Otherwise null is returned.


setContentType

public void setContentType(String contentType)
Sets the CONTENT_TYPE property to contentType if not null.


getContentType

public String getContentType()
Returns the CONTENT_TYPE property if not null and a String instance. Otherwise null is returned.


setContentLength

public void setContentLength(long contentLength)
Sets the CONTENT_LENGTH property to contentType if not null.


getContentLength

public long getContentLength()
Returns the CONTENT_LENGTH property if not null and a long. Otherwise -1 is returned.


setCreationTime

public void setCreationTime(long creationTime)
Sets the CREATION_TIME property to creationTime if not negative.


getCreationTime

public long getCreationTime()
Returns the CREATION_TIME property if not null and a long. Otherwise -1 is returned.


setModificationTime

public void setModificationTime(long modificationTime)
Sets the MODIFICATION_TIME property to modificationTime if not negative.


getModificationTime

public long getModificationTime()
Returns the MODIFICATION_TIME property if not null and a long. Otherwise -1 is returned.


setResolutionPath

public void setResolutionPath(String resolutionPath)
Sets the RESOLUTION_PATH property to resolutionPath if not null.


getResolutionPath

public String getResolutionPath()
Returns the RESOLUTION_PATH property if not null and a String instance. Otherwise null is returned.


setResolutionPathInfo

public void setResolutionPathInfo(String resolutionPathInfo)
Sets the RESOLUTION_PATH_INFO property to resolutionPathInfo if not null.


getResolutionPathInfo

public String getResolutionPathInfo()
Returns the RESOLUTION_PATH_INFO property if not null and a String instance. Otherwise null is returned.



Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.