Package org.outerj.expression

Examples of org.outerj.expression.Expression


        String exactExprString = validationRuleElement.getAttribute("exact");
        String minExprString = validationRuleElement.getAttribute("min");
        String maxExprString = validationRuleElement.getAttribute("max");

        if (exactExprString.length() > 0) {
            Expression expression = parseExpression(exactExprString, validationRuleElement, "exact");
            rule.setExactExpr(expression);
        } else if (minExprString.length() > 0 && maxExprString.length() > 0) {
            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
            rule.setMinExpr(expression);
            expression = parseExpression(maxExprString, validationRuleElement, "max");
            rule.setMaxExpr(expression);
        } else if (minExprString.length() > 0) {
            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
            rule.setMinExpr(expression);
        } else if (maxExprString.length() > 0) {
            Expression expression = parseExpression(maxExprString, validationRuleElement, "max");
            rule.setMaxExpr(expression);
        } else {
            throw new Exception("length validation rule requires a min and/or max, or exact attribute at " + DomHelper.getLocation(validationRuleElement));
        }
View Full Code Here


        String minExprString = validationRuleElement.getAttribute("min");
        String maxExprString = validationRuleElement.getAttribute("max");

        if (minExprString.length() > 0 && maxExprString.length() > 0) {
            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
            rule.setMinExpr(expression);
            expression = parseExpression(maxExprString, validationRuleElement, "max");
            rule.setMaxExpr(expression);
        } else if (minExprString.length() > 0) {
            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
            rule.setMinExpr(expression);
        } else if (maxExprString.length() > 0) {
            Expression expression = parseExpression(maxExprString, validationRuleElement, "max");
            rule.setMaxExpr(expression);
        } else {
            throw new Exception("range validation rule requires a min and/or max attribute at " + DomHelper.getLocation(validationRuleElement));
        }
View Full Code Here

public class AssertValidationRuleBuilder extends AbstractValidationRuleBuilder {
    public ValidationRule build(Element validationRuleElement) throws Exception {
        String exprStr = validationRuleElement.getAttribute("test");
        if (exprStr.length() == 0)
            throw new Exception("assert validation rule requires a \"test\" attribute at " + DomHelper.getLocation(validationRuleElement));
        Expression testExpression = parseExpression(exprStr, validationRuleElement, "test");
        if (testExpression.getResultType() != null && !Boolean.class.isAssignableFrom(testExpression.getResultType()))
            throw new Exception("Expression should evaluate to a boolean on assert validation rule at " + DomHelper.getLocation(validationRuleElement));
        AssertValidationRule rule = new AssertValidationRule(testExpression);
        buildFailMessage(validationRuleElement, rule);
        return rule;
    }
View Full Code Here

        String exactExprString = validationRuleElement.getAttribute("exact");
        String minExprString = validationRuleElement.getAttribute("min");
        String maxExprString = validationRuleElement.getAttribute("max");

        if (exactExprString.length() > 0) {
            Expression expression = parseExpression(exactExprString, validationRuleElement, "exact");
            rule.setExactExpr(expression);
        } else if (minExprString.length() > 0 && maxExprString.length() > 0) {
            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
            rule.setMinExpr(expression);
            expression = parseExpression(maxExprString, validationRuleElement, "max");
            rule.setMaxExpr(expression);
        } else if (minExprString.length() > 0) {
            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
            rule.setMinExpr(expression);
        } else if (maxExprString.length() > 0) {
            Expression expression = parseExpression(maxExprString, validationRuleElement, "max");
            rule.setMaxExpr(expression);
        } else {
            throw new Exception("value-count validation rule requires a min and/or max, or exact attribute at " + DomHelper.getLocation(validationRuleElement));
        }
View Full Code Here

    protected Expression setupExpression(String formula) throws Exception {
        return expressionManager.parse(formula);
    }
   
    protected void setupExpression(String formula, SimpleFormula algo) throws Exception {
        Expression expression = expressionManager.parse(formula);
        algo.setFormula(expression);
        List vars = expressionManager.parseVariables(formula);
        for (Iterator iter = vars.iterator(); iter.hasNext();) {
            VariableFunction var = (VariableFunction) iter.next();
            algo.addTrigger(var.getVariableName());
View Full Code Here

        String repeatOn = DomHelper.getAttribute(algorithmElement, "repeat-on");
        ret.setRepeatOn(repeatOn);
        ret.addTrigger(repeatOn);
       
        String initialResult = DomHelper.getAttribute(algorithmElement, "initial-result");
        Expression expression = setupExpression(initialResult);
        ret.setInitialResult(expression);
        super.setup(algorithmElement, ret);
        return ret;
    }
View Full Code Here

        }

        // compile combine expression
        Element combineElement = DomHelper.getChildElement(widgetElement, Constants.WD_NS, "combine", true);
        String combineExprString = DomHelper.getAttribute(combineElement, "expression");
        Expression combineExpr = null;
        try {
            combineExpr = expressionManager.parse(combineExprString);
        } catch (Exception e) {
            throw new Exception("Problem with combine expression defined at " + DomHelper.getLocation(combineElement) + ": " + e.getMessage());
        }
        if (combineExpr.getResultType() != null && !String.class.isAssignableFrom(combineExpr.getResultType()))
            throw new Exception("The result of the combine expression should be a string, at " + DomHelper.getLocation(combineElement));
        definition.setCombineExpression(combineExpr);

        // add validation rules
        Element validationElement = DomHelper.getChildElement(widgetElement, Constants.WD_NS, "validation", false);
View Full Code Here

        }

        // compile combine expression
        Element combineElement = DomHelper.getChildElement(widgetElement, Constants.WD_NS, "combine", true);
        String combineExprString = DomHelper.getAttribute(combineElement, "expression");
        Expression combineExpr = null;
        try {
            combineExpr = expressionManager.parse(combineExprString);
        } catch (Exception e) {
            throw new Exception("Problem with combine expression defined at " + DomHelper.getLocation(combineElement) + ": " + e.getMessage());
        }
        if (combineExpr.getResultType() != null && !String.class.isAssignableFrom(combineExpr.getResultType()))
            throw new Exception("The result of the combine expression should be a string, at " + DomHelper.getLocation(combineElement));
        definition.setCombineExpression(combineExpr);

        // add validation rules
        Element validationElement = DomHelper.getChildElement(widgetElement, Constants.WD_NS, "validation", false);
View Full Code Here

    public Expression parse(String expressionString) throws ParseException, ExpressionException {
        FormulaParser parser = new FormulaParser(new java.io.StringReader(expressionString), factory);
        parser.parse();

        Expression expression = parser.getExpression();
        expression.check();

        return expression;
    }
View Full Code Here

    public Expression parse(String expressionString) throws ParseException, ExpressionException {
       
        FormulaParser parser = new FormulaParser(new java.io.StringReader(expressionString), factory);
        parser.sum();

        Expression expression = parser.getExpression();
        expression.check();

        return expression;
    }
View Full Code Here

TOP

Related Classes of org.outerj.expression.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.