jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Nuescheler <david.nuesche...@gmail.com>
Subject Re: getString for multi-valued properties
Date Tue, 01 Mar 2005 05:05:35 GMT
> The First Steps document was probably written when Jackrabbit wasn't
> returning multi-values for the example cases. Nowadays at least the
> jcr:mixinTypes property is multivalued and requires special handling.
i think it was written when getString on an mvp didn't throw... 

> Among other updates to the First Steps document, I recently changed
> property display code to the following. The changes are already visible
> on the web site.
thanks a lot. looks good.

>    Property p=pit.nextProperty();
>    System.out.print(p.getPath() + "=");
>    if (p.getDefinition().isMultiple()) {
>        Value[] values = p.getValues();
>        for (int i = 0; i < values.length; i++) {
>            if (i > 0) System.out.println(",");
>            System.out.println(values[i].getString());
>        }
>    } else {
>        System.out.print(p.getString());
>    }
>    System.out.println();
> 
> It's not as straightforward as one might wish, but this is what the spec
> requires. Should we start a "JCR code idioms" document somewhere (the
> dormant wiki perhaps)? 
how about an "examples"-contrib in svn? i think a sample
webapp could help people to kickstart their work with 
jackrabbit.

> The general-case property value access code would
> be:
> 
>    Property property = ...;
>    if (property.getDefinition().isMultiple()) {
>        Value[] values = property.getValues();
>        for (int i = 0; i < values.length; i++) {
>            processValue(values[i]);
>        }
>    } else {
>        processValue(property.getValue());
>    }

hmmm... looking at that, i agree that it doesn't 
look very pretty. i would argue though that 
there are only few "generic"-applications
like a general purpose repository browser 
or an eclipse plug-in that would have to 
access information in such a manner
(and even those will probably work differently 
for mvp & svp). my argument would be 
that most content applications 
(hopefully) know their underlying 
content-model and therefore "know" if
a property is multi-value or not.
i think of all the display logic templates
or content management apps, they 
should all be aware of the content 
model that they are operating 
against? thoughts?

regards,
david

Mime
View raw message