public class AndFactory implements EvaluatorFactory {
private Log log = LogFactory.getLog(AndFactory.class);
public Evaluator create(OMElement e) throws EvaluatorException {
AndEvaluator o = new AndEvaluator();
Iterator it = e.getChildElements();
List<Evaluator> evaluators = new ArrayList<Evaluator>();
while (it.hasNext()) {
OMElement evaluatorElement = (OMElement) it.next();
EvaluatorFactory ef = EvaluatorFactoryFinder.getInstance().
findEvaluatorFactory(evaluatorElement.getLocalName());
if (ef == null) {
handleException("Invalid configuration element: " +
evaluatorElement.getLocalName());
return null;
}
Evaluator evaluator = ef.create(evaluatorElement);
evaluators.add(evaluator);
}
if (evaluators.size() > 1) {
o.setEvaluators(evaluators.toArray(new Evaluator[evaluators.size()]));
} else {
handleException("Two or more expressions " +
"should be provided under And");
return null;
}