@Override public Item item(final QueryContext qc, final InputInfo ii) throws QueryException { // compute scoring if (qc.scoring) { double s = 0; boolean f = false; for (final Expr expr : exprs) { final Item it = expr.ebv(qc, info); f |= it.bool(ii); s += it.score(); } return Bln.get(f, Scoring.avg(s, exprs.length)); } // standard evaluation for (final Expr expr : exprs) { if (expr.ebv(qc, info).bool(ii)) return Bln.TRUE; } return Bln.FALSE; }
/** * Checks if the specified item is a boolean. Returns the boolean or throws an exception. * * @param it item be checked * @return boolean * @throws QueryException query exception */ protected final boolean toBoolean(final Item it) throws QueryException { final Type ip = checkNoEmpty(it, AtomType.BLN).type; if (ip == AtomType.BLN) return it.bool(info); if (ip.isUntyped()) return Bln.parse(it.string(info), info); throw castError(it, AtomType.BLN, info); }
@Override public final Item test(final QueryContext qc, final InputInfo ii) throws QueryException { final Item it = ebv(qc, info); return (it instanceof ANum ? it.dbl(info) == qc.pos : it.bool(info)) ? it : null; }