Package org.springmodules.validation.valang.parser

Examples of org.springmodules.validation.valang.parser.ValangParser


     * @param expression The given argument expression.
     * @param functionsByName The custom valang functions.
     * @return The parsed function.
     */
    protected Function parseFunction(String expression, Map functionsByName) {
        ValangParser parser = new ValangParser(new StringReader(expression));
        parser.setFunctionsByName(functionsByName);
        try {
            return parser.function(new TargetBeanFunction());
        } catch (ParseException pe) {
            logger.error("Could not parse valang expression '" + expression + "' to a function", pe);
            throw new IllegalArgumentException("Could not parse valang expression '" + expression + "' to a function");
        }
    }
View Full Code Here


     * @param expression The given argument expression.
     * @param functionsByName The custom valang functions.
     * @return The parsed function.
     */
    protected Function parseFunction(String expression, Map functionsByName) {
        ValangParser parser = new ValangParser(new StringReader(expression));
        parser.setFunctionsByName(functionsByName);
        try {
            return parser.function(new TargetBeanFunction());
        } catch (ParseException pe) {
            logger.error("Could not parse valang expression '" + expression + "' to a function", pe);
            throw new IllegalArgumentException("Could not parse valang expression '" + expression + "' to a function");
        }
    }
View Full Code Here

    protected void tearDown() throws Exception {
        Context.exit();
    }

    private ValangParser getParser(String text) {
        return new ValangParser(new StringReader(text));
    }
View Full Code Here

        private org.springmodules.validation.valang.functions.Function valangFunction;

        public ValangFunction(String valangExpression) {
            this.valangExpression = valangExpression;
            ValangParser parser = createValangParser(valangExpression);
            try {
                this.valangFunction = parser.function(new TargetBeanFunction());
            } catch (ParseException pe) {
                throw new FelParseException("Could not parse valang function expression '" +
                    valangExpression + "'", pe);
            }
        }
View Full Code Here

        if (text == null || text.trim().length() == 0) {
            logger.debug("No text to parse");
            return null;
        }

        ValangParser parser = new ValangParser(text, null, null); // text -> predicate tree
        ValangJavaScriptTranslator translator = new ValangJavaScriptTranslator(); // pt -> js

        StringWriter sw = new StringWriter();
        Predicate pred;

        try {
            pred = parser.parseExpression();
            translator.writeJavaScriptPredicate(sw, pred);

        } catch (ParseException e) {
            logger.debug("Valang failed parsing.");
            return null;
View Full Code Here

        }
    }

    protected Collection parseRulesFromBodyContent() throws JspException {
        try {
            return new ValangParser(bodyContent.getReader()).parseValidation();
        }
        catch (ParseException e) {
            throw new JspException("Could not parse valang", e);
        }
    }
View Full Code Here

        return rules;
    }

    public void afterPropertiesSet() throws Exception {
        Assert.hasLength(getValang(), "'valang' property must be set!");
        ValangParser parser = createValangParser(getValang());
        rules = parser.parseValidation();
    }
View Full Code Here

        }
    }

    protected Collection parseRulesFromBodyContent() throws JspException {
        try {
            return new ValangParser(bodyContent.getReader()).parseValidation();
        }
        catch (ParseException e) {
            throw new JspException("Could not parse valang", e);
        }
    }
View Full Code Here

     */
    @Override
    public void afterPropertiesSet() throws Exception {
        Assert.hasLength(getValang(), "'valang' property must be set!");

        ValangParser parser = null;

        if (!StringUtils.hasText(className)) {
            parser = createValangParser(valang);
        } else {
            parser = createValangParser(valang, className);

            // if className is set, this is the only supported class
            // for this validator
            supportClass = ClassUtils.forName(className, ClassUtils.getDefaultClassLoader());
        }

        rules = parser.parseValidation();
    }
View Full Code Here

    protected void tearDown() throws Exception {
        Context.exit();
    }

    private ValangParser getParser(String text) {
        return new ValangParser(new StringReader(text));
    }
View Full Code Here

TOP

Related Classes of org.springmodules.validation.valang.parser.ValangParser

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.