Hi,
Carsten Ziegeler schrieb:
Felix Meschberger wrote:
>> This interface will primarily be used to implement the [Value]Map
adapter for JCR Node based resources but may also be used for other
adapters to be done in the future - e.g. an adapter for Bundle-based
Properties files which provide the properties data.
The interface would live in the org.apache.sling.api.resource and
therefore be an enhancement of the Sling API.
Yes, sounds good to me - I guess it will still be possible to just adapt
a resource to a plain old Map :)
Yes, Resource.adaptTo(Map.class) would return the same in the case of
JCR-Node based resources.
Just one question= What happens if the value can't be converted to the
given type? Will just null be returned or an exception thrown (I imagine
the latter)?
The Adaptable.adaptTo JavaDoc states: "The adapter target or
<code>null</code> if the resource cannot adapt to the requested type".
Thus if an object can be adapted, it is is. Otherwise null is returned.
The reason for this is, that we cannot preclude the set of target
classes for any one implementation. This set is even extensible when
using AdapterFactorys and SlingAdaptable. So I consider not being able
to map not a problem but an expected situation.
Hope this helps.
Regards
Felix