use of org.apache.jackrabbit.core.value.ValueFactoryImpl in project jackrabbit by apache.
the class LengthOperand method getValues.
/**
* {@inheritDoc}
*/
public Value[] getValues(ScoreNode sn, EvaluationContext context) throws RepositoryException {
PropertyState ps = property.getPropertyState(sn, context);
if (ps == null) {
return EMPTY;
} else {
ValueFactoryImpl vf = (ValueFactoryImpl) context.getSession().getValueFactory();
QValueFactory qvf = vf.getQValueFactory();
InternalValue[] values = ps.getValues();
Value[] lengths = new Value[values.length];
for (int i = 0; i < lengths.length; i++) {
long len;
int type = values[i].getType();
if (type == PropertyType.NAME) {
len = vf.createValue(qvf.create(values[i].getName())).getString().length();
} else if (type == PropertyType.PATH) {
len = vf.createValue(qvf.create(values[i].getPath())).getString().length();
} else {
len = Util.getLength(values[i]);
}
lengths[i] = vf.createValue(len);
}
return lengths;
}
}
Aggregations