I believe it would be possible to implement
AbstractResource#adaptTo(ValueMap.class) in a generic way supporting
relative paths.
A rarely used feature (at least of the JcrResourceProvider) is to
request a property as a Resource (e.g.
resource.getResource("jcr:title").adaptTo(String.class)). If the
contract of ResourceResolver#getResource(Resource base, String path)
was clarified to provide each property as a Resource, this method
could be used
to implement a deep ValueMap.
public DeepValueMap implements ValueMap {
public T get(String relPath, T type) {
Resource descendant = resource.getChild(relPath);
if (descendant == null) {
return null;
} else {
return descendant.adaptTo(type);
}
}
// other methods and constructors ommitted for brevity
}
In addition, it may be useful for ResourceProvider implementation if a
reusable ValueResource class was available to cast to the different
property types (e.g. the Java equivalents of JCR property types).
Regards
Julian
On Fri, Mar 14, 2014 at 11:58 AM, Carsten Ziegeler <[email protected]> wrote:
> Well, in practice, bundles implementing a previous version will not resolve
> anyway
>
>
> 2014-03-14 11:56 GMT+01:00 Bertrand Delacretaz <[email protected]>:
>
>> On Fri, Mar 14, 2014 at 11:53 AM, Carsten Ziegeler <[email protected]>
>> wrote:
>> > All implementations should inherit from AbstractResource for exactly
>> those
>> > reasons :)
>>
>> *in theory*, yes.
>>
>> -Bertrand
>>
>
>
>
> --
> Carsten Ziegeler
> [email protected]