throws AlgebricksException {
final SequencePointable seqp = new SequencePointable();
final LongPointable lp = (LongPointable) LongPointable.FACTORY.createPointable();
final IntegerPointable ip = (IntegerPointable) IntegerPointable.FACTORY.createPointable();
final ShortPointable sp = (ShortPointable) ShortPointable.FACTORY.createPointable();
final BytePointable bp = (BytePointable) BytePointable.FACTORY.createPointable();
final XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
final DoublePointable dp = (DoublePointable) DoublePointable.FACTORY.createPointable();
final FloatPointable fp = (FloatPointable) FloatPointable.FACTORY.createPointable();
final UTF8StringPointable utf8p = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
return new AbstractTaggedValueArgumentScalarEvaluator(args) {
@Override
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
TaggedValuePointable tvp = args[0];
switch (tvp.getTag()) {
case ValueTag.SEQUENCE_TAG: {
tvp.getValue(seqp);
if (seqp.getEntryCount() == 0) {
XDMConstants.setFalse(result);
return;
}
XDMConstants.setTrue(result);
return;
}
case ValueTag.XS_BOOLEAN_TAG: {
result.set(tvp);
return;
}
case ValueTag.XS_DECIMAL_TAG: {
tvp.getValue(decp);
if (decp.longValue() == 0) {
XDMConstants.setFalse(result);
return;
}
XDMConstants.setTrue(result);
return;
}
case ValueTag.XS_INTEGER_TAG:
case ValueTag.XS_LONG_TAG:
case ValueTag.XS_NEGATIVE_INTEGER_TAG:
case ValueTag.XS_NON_POSITIVE_INTEGER_TAG:
case ValueTag.XS_NON_NEGATIVE_INTEGER_TAG:
case ValueTag.XS_POSITIVE_INTEGER_TAG:
case ValueTag.XS_UNSIGNED_INT_TAG:
case ValueTag.XS_UNSIGNED_LONG_TAG: {
tvp.getValue(lp);
if (lp.longValue() == 0) {
XDMConstants.setFalse(result);
return;
}
XDMConstants.setTrue(result);
return;
}
case ValueTag.XS_INT_TAG:
case ValueTag.XS_UNSIGNED_SHORT_TAG: {
tvp.getValue(ip);
if (ip.intValue() == 0) {
XDMConstants.setFalse(result);
return;
}
XDMConstants.setTrue(result);
return;
}
case ValueTag.XS_SHORT_TAG:
case ValueTag.XS_UNSIGNED_BYTE_TAG: {
tvp.getValue(sp);
if (sp.shortValue() == 0) {
XDMConstants.setFalse(result);
return;
}
XDMConstants.setTrue(result);
return;
}
case ValueTag.XS_BYTE_TAG: {
tvp.getValue(bp);
if (bp.byteValue() == 0) {
XDMConstants.setFalse(result);
return;
}
XDMConstants.setTrue(result);
return;