org.apache.sling.api.resource
Interface ValueMap

All Superinterfaces:
Map<String,Object>
All Known Subinterfaces:
PersistableValueMap, Profile, Style, UserState
All Known Implementing Classes:
MergedValueMap, ValueMapDecorator

public interface ValueMap
extends Map<String,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
Map.Entry<K,V>
 
Field Summary
static ValueMap EMPTY
          Empty immutable value map.
 
Method Summary
<T> T
get(String name, Class<T> type)
          Get a named property and convert it into the given type.
<T> T
get(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 immutable value map.

Method Detail

get

<T> T get(String name,
          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(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 © 1993-2010 Day Management AG. All Rights Reserved.