/** * Evaluates this predicate on the given argument * * @param record * the record to test. It will be inject in the javascript * context using getRecordKey() * @return true (keep) if the user script returned 1 or true, else false * (reject). */ protected boolean accept(final TYPE record) { try { /* insert the record into the javascript context */ this.bindings.put(getRecordKey(), record); /* get the result */ final Object result = this.script.eval(this.bindings); if (result == null) { return false; } else if (result instanceof Boolean) { return Boolean.TRUE.equals(result); } else if (result instanceof Number) { return (((Number) result).intValue() == 1); } else { return false; } } catch (ScriptException err) { throw new RuntimeException(err); } } }
/** * Evaluates this predicate on the given argument * * @param record * the record to test. It will be inject in the javascript * context using getRecordKey() * @return true (keep) if the user script returned 1 or true, else false * (reject). */ protected boolean accept(final TYPE record) { try { /* insert the record into the javascript context */ this.bindings.put(getRecordKey(), record); /* get the result */ final Object result = this.script.eval(this.bindings); if (result == null) { return false; } else if (result instanceof Boolean) { return Boolean.TRUE.equals(result); } else if (result instanceof Number) { return (((Number) result).intValue() == 1); } else { return false; } } catch (ScriptException err) { throw new RuntimeException(err); } } }