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;
}
case ValueTag.XS_DOUBLE_TAG: {
tvp.getValue(dp);
if (dp.doubleValue() == 0 || Double.isNaN(dp.doubleValue())) {
XDMConstants.setFalse(result);
return;
}
XDMConstants.setTrue(result);
return;
}
case ValueTag.XS_FLOAT_TAG: {
tvp.getValue(fp);
if (fp.floatValue() == 0 || Float.isNaN(fp.floatValue())) {
XDMConstants.setFalse(result);
return;
}
XDMConstants.setTrue(result);
return;
}
case ValueTag.XS_ANY_URI_TAG:
case ValueTag.XS_STRING_TAG: {
tvp.getValue(utf8p);
if (utf8p.getUTFLength() == 0) {
XDMConstants.setFalse(result);
return;
}
XDMConstants.setTrue(result);
return;