org.apache.sling.api.resource
Interface ValueMap

All Superinterfaces:
java.util.Map<java.lang.String,java.lang.Object>
All Known Subinterfaces:
PersistableValueMap
All Known Implementing Classes:
AuthorizableValueMap, JcrModifiablePropertyMap, JcrPropertyMap, ValueMapDecorator

public interface ValueMap
extends java.util.Map<java.lang.String,java.lang.Object>

The ValueMap is an easy way to access properties of a resource. With most resources you can use Adaptable.adaptTo(Class) to adapt the resource to a value map. The various getter methods can be used to get the properties of the resource.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
static ValueMap EMPTY
          Empty value map
 
Method Summary
<T> T
get(java.lang.String name, java.lang.Class<T> type)
          Get a named property and convert it into the given type.
<T> T
get(java.lang.String name, T defaultValue)
          Get a named property and convert it into the given type.
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Field Detail

EMPTY

static final ValueMap EMPTY
Empty value map

Method Detail

get

<T> T get(java.lang.String name,
          java.lang.Class<T> type)
Get a named property and convert it into the given type.

Parameters:
name - The name of the property
type - The class of the type
Returns:
Return named value converted to type T or null if non existing or can't be converted.

get

<T> T get(java.lang.String name,
          T defaultValue)
Get a named property and convert it into the given type.

Parameters:
name - The name of the property
defaultValue - The default value to use if the named property does not exist or cannot be converted to the requested type. The default value is also used to define the type to convert the value to. If this is null any existing propert is not converted.
Returns:
Return named value converted to type T or the default value if non existing or can't be converted.


Copyright © 2007-2009. All Rights Reserved.