Search in sources :

Example 1 with AndEvaluator

use of org.apache.synapse.commons.evaluators.AndEvaluator in project wso2-synapse by wso2.

the class AndSerializer method serialize.

public OMElement serialize(OMElement parent, Evaluator evaluator) throws EvaluatorException {
    if (!(evaluator instanceof AndEvaluator)) {
        throw new IllegalArgumentException("Evalutor should be a AndEvalutor");
    }
    AndEvaluator andEvaluator = (AndEvaluator) evaluator;
    OMElement andElement = fac.createOMElement(EvaluatorConstants.AND, EvaluatorConstants.SYNAPSE_NAMESPACE, EvaluatorConstants.EMPTY_PREFIX);
    serializeChildren(andElement, andEvaluator.getEvaluators());
    if (parent != null) {
        parent.addChild(andElement);
    }
    return andElement;
}
Also used : OMElement(org.apache.axiom.om.OMElement) AndEvaluator(org.apache.synapse.commons.evaluators.AndEvaluator)

Example 2 with AndEvaluator

use of org.apache.synapse.commons.evaluators.AndEvaluator in project wso2-synapse by wso2.

the class AndFactory method create.

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;
    }
    return o;
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) OMElement(org.apache.axiom.om.OMElement) AndEvaluator(org.apache.synapse.commons.evaluators.AndEvaluator) Evaluator(org.apache.synapse.commons.evaluators.Evaluator) AndEvaluator(org.apache.synapse.commons.evaluators.AndEvaluator)

Aggregations

OMElement (org.apache.axiom.om.OMElement)2 AndEvaluator (org.apache.synapse.commons.evaluators.AndEvaluator)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Evaluator (org.apache.synapse.commons.evaluators.Evaluator)1