org.apache.sling.api.resource
Interface ValueMap
- All Superinterfaces:
- Map<String,Object>
- All Known Subinterfaces:
- PersistableValueMap
- All Known Implementing Classes:
- JcrModifiablePropertyMap, JcrPropertyMap, 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 classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
Method Summary |
|
get(String name,
Class<T> type)
Get a named property and convert it into the given type. |
|
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 |
EMPTY
static final ValueMap EMPTY
- Empty immutable value map.
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 propertytype
- 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 propertydefaultValue
- 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 property 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-2011 The Apache Software Foundation. All Rights Reserved.