jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jaka Jaksic" <jaka.jak...@telemach.net>
Subject Property serialization in document view
Date Wed, 26 Jul 2006 01:42:17 GMT

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
			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:


...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.


View raw message