{
public final Expr evaluate(Expr[] args) throws ExprException {
assertArgCount(args, 3);
// Get database argument
Expr edb = evalArg(args[0]);
if (!(edb instanceof ExprArray)) {
return ExprError.VALUE;
}
Database db = Database.valueOf((ExprArray) edb);
if (db == null) {
return ExprError.VALUE;
}
// Get field argument
Expr ef = evalArg(args[1]);
String field = null;
if (ef instanceof ExprString) {
field = ((ExprString) ef).str;
} else if (ef instanceof ExprInteger) {
int col = ((ExprInteger) ef).intValue();
int cc = db.getColumnCount();
if (col < 1 || col > cc)
return ExprError.VALUE;
field = db.getColumnName(col - 1);
}
// Get criteria argument
Expr ec = evalArg(args[2]);
if (!(ec instanceof ExprArray)) {
return ExprError.VALUE;
}
Criteria criteria = Criteria.valueOf((ExprArray) ec);