jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Guggisberg" <stefan.guggisb...@gmail.com>
Subject Re: Property serialization in document view
Date Mon, 31 Jul 2006 15:20:29 GMT
hi jaka,
what version of jackrabbit are you refering to? the current svn HEAD rev.
of DocViewSAXEventGenerator.java does not contain the quoted
code.

cheers
stefan

On 7/26/06, Jaka Jaksic <jaka.jaksic@telemach.net> wrote:
> Hi!
>
> I have some suggestions about property serialization in document view,
> namely this block of code in DocViewSAXEventGenerator:
>
>         StringBuffer attrValue = new StringBuffer();
>         // process property value(s)
>         boolean multiValued = prop.getDefinition().isMultiple();
>         Value[] vals;
>         if (multiValued) {
>                 vals = prop.getValues();
>         } else {
>                 vals = new Value[]{prop.getValue()};
>         }
>         for (int i = 0; i < vals.length; i++) {
>                 if (i > 0) {
>                         // use space as delimiter for multi-valued
> properties
>                         attrValue.append(" ");
>                 }
>                 attrValue.append(ValueHelper.serialize(vals[i], true));
>         }
>
> This calls ValueHelper.serialize() with the parameter encodeBlanks=true,
> which replaces spaces with "_x0020_". As I understand, this is needed
> because space is used as a delimiter in multi-valued properties. But this
> way spaces are also replaced in single-valued properties, which is
> unnecessary and awkward. So I think that line should read:
>
>                 attrValue.append(ValueHelper.serialize(vals[i],
> multiValued));
>
> ...to only replace spaces in multi-valued properties.
>
> Another small thing I noticed is that a new StringBuffer is created for
> every serialized property, which is a waste of resources. It would be better
> (and no more complicated) if a single StringBuffer was created before the
> loop and then reused for all properties.
>
>
> Regards,
> Jaka
>
>

Mime
View raw message