// iteration of the filter expression than are absolutely essential.
// The code is almost identical to the code in ExpressionTool#effectiveBooleanValue
// except for the handling of a numeric result
SequenceIterator iterator = filter.iterate(filterContext);
Item first = iterator.next();
if (first == null) {
return false;
}
if (first instanceof NodeInfo) {
return true;
} else {
if (first instanceof BooleanValue) {
if (iterator.next() != null) {
ExpressionTool.ebvError("sequence of two or more items starting with a boolean");
}
return ((BooleanValue)first).getBooleanValue();
} else if (first instanceof StringValue) {
if (iterator.next() != null) {
ExpressionTool.ebvError("sequence of two or more items starting with a string");
}
return (first.getStringValueCS().length()!=0);
} else if (first instanceof Int64Value) {
if (iterator.next() != null) {
ExpressionTool.ebvError("sequence of two or more items starting with a numeric value");
}
return ((Int64Value)first).longValue() == base.position();
} else if (first instanceof NumericValue) {
if (iterator.next() != null) {
ExpressionTool.ebvError("sequence of two or more items starting with a numeric value");
}
return ((NumericValue)first).compareTo(base.position()) == 0;
} else {
ExpressionTool.ebvError("sequence starting with an atomic value other than a boolean, number, or string");