public class ComponentInheritanceValueMap extends ValueMapWrapper implements InheritanceValueMap
InheritanceValueMap
for a given Resource
that will inherit values from
ancestors up to its ancestral component, but no higher.
For example, given: /content/parent/page/jcr:content/footer/image/@width
,
the ComponentInheritanceValueMap
will search for a width property in:
/content/parent/page/jcr:content/footer/image/@width
/content/parent/page/jcr:content/footer/@width
/content/parent/page/jcr:content/@width
null
.
Note that ComponentInheritanceValueMap
searches only the component
hierarchy. It will not (for instance), look in:
/content/parent/jcr:content/footer/image/@width
HierarchyNodeInheritanceValueMap
for that
functionality.Constructor and Description |
---|
ComponentInheritanceValueMap(Resource resource)
Will wrap the
ValueMap returned by
resource.adaptTo(ValueMap.class) , or use an empty map if
resource is null or if it doesn't adapt to a ValueMap. |
ComponentInheritanceValueMap(ValueMap map)
|
Modifier and Type | Method and Description |
---|---|
<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 |
getInherited(java.lang.String name,
java.lang.Class<T> type)
Get a named property and convert it into the given type, and take the
properties of parent resources / pages into account, if the property is
not found locally.
|
<T> T |
getInherited(java.lang.String name,
T defaultValue)
Get a named property and convert it into the given type, and take the
properties of parent resources / pages into account, if the property is
not found locally.
|
clear, containsKey, containsValue, entrySet, get, get, isEmpty, keySet, put, putAll, remove, size, toString, values
public ComponentInheritanceValueMap(Resource resource)
ValueMap
returned by
resource.adaptTo(ValueMap.class)
, or use an empty map if
resource
is null or if it doesn't adapt to a ValueMap. The
inheritance is internally resolved by fetching the parent resource and
wrapping it into an ComponentInheritanceValueMap
as well.resource
- the resource to start frompublic ComponentInheritanceValueMap(ValueMap map)
Resource
for a ValueMap
is not
available and no inheritance is needed. Using the inheritance-enabled
getter
methods
will behave exactly like
the normal ValueMap getters.map
- a ValueMap to wrappublic <T> T get(java.lang.String name, java.lang.Class<T> type)
ValueMap
null
in this
case.get
in interface ValueMap
get
in class ValueMapWrapper
T
- The class of the typename
- The name of the propertytype
- The class of the typenull
if
non existing or can't be converted.public <T> T getInherited(java.lang.String name, java.lang.Class<T> type)
InheritanceValueMap
The exact inheritance mechanism depends on the implementation.
getInherited
in interface InheritanceValueMap
T
- type parametername
- The name of the propertytype
- The class of the typenull
if
non existing or can't be converted.public <T> T getInherited(java.lang.String name, T defaultValue)
InheritanceValueMap
The exact inheritance mechanism depends on the implementation.
getInherited
in interface InheritanceValueMap
T
- type parametername
- 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.Copyright © 2010 - 2020 Adobe. All Rights Reserved