Am Freitag, den 30.11.2007, 08:34 +0100 schrieb Bertrand Delacretaz:
> On Nov 30, 2007 8:22 AM, Felix Meschberger <[EMAIL PROTECTED]> wrote:
>
> > ...An extended more flexible solution would be something like this:
> >
> > public interface Resource {
> > ....
> > // get this resource as an object of the type or null if not
> > possible
> > <T> T adaptTo(Class<T> type);
> > }...
>
> Very interesting - this means basically delegating the typecast to the
> Resource itself, which is best placed to know whether the cast makes
> sense or not. I like that.
Yes, and the Resoure may even adapt to more types by applying some more
logic, for example a Resource may support adapting to a DOM Document
returning the Node subtree as a DOM Document, or it may adapt to a
JSONObject returning the Node subtree as a JSON object ....
We might even be able to drop these XXXProvider interfaces again,
because they would not be needed. The Resource knows whether it has a
node and just returns that node, without even having to cast something.
And best of all: We dropped the singular reference to the JCR API
again :-)
Regards
Felix