if (!(d1 instanceof DataAtom) || !(d2 instanceof DataAtom)){
throw new RuntimeException("Builtin functions cannot be used to compare non-atomic values. Use a filter function instead.");
}
DataAtom da1 = (DataAtom)d1;
DataAtom da2 = (DataAtom)d2;
char op1 = op.charAt(0);
char op2 = op.length() >= 2 ? op.charAt(1) : '0';
char op3 = op.length() == 3 ? op.charAt(2) : '0';
switch (op1) {
// numeric ops first
case '=':
if (op2 == '=') {
return da1.numval().equals(da2.numval());
} else {
throw new RuntimeException("Internal error: Invalid filter operator: " + op);
}
case '<':
if (op2 == '=') {
return da1.numval().compareTo(da2.numval()) <= 0;
} else {
return da1.numval().compareTo(da2.numval()) < 0;
}
case '>':
if (op2 == '=') {
return da1.numval().compareTo(da2.numval()) >= 0;
} else {
return da1.numval().compareTo(da2.numval()) > 0;
}
case '!':
if (op2 == '=') {
return !da1.numval().equals(da2.numval());
} else {
throw new RuntimeException("Internal error: Invalid filter operator: " + op);
}
// now string ops
case 'e':