Package net.sourceforge.temply.base.rules

Examples of net.sourceforge.temply.base.rules.Rule


   
    /**
     * force a resolution for the given rule and mainCategory to use the given path
     */
    public void forcePath(String ruleName, String mainCategory, List<PathEntry> path) {
        Rule rule = _project.getRepository().getRule(ruleName);
        if (rule == null) {
            throw new IllegalArgumentException("Cannot find rule \"" + ruleName + "\".");
        }

        for (Var var : rule.getVars()) {
            _forcedPaths.put(new VarExpression(rule, Utils.getCategories(mainCategory), var), path);
        }
    }
View Full Code Here


    public Rule addResolve(String resolveRuleName, String varName, String value) {
        return addResolve(resolveRuleName, varName, value, null);
    }
   
    public boolean remove(String ruleName) {
        Rule rule = _project.getRepository().getRule(ruleName);
        if (rule == null) {
            throw new RuntimeException("Cannot find rule " + ruleName);
        }
        return _rules.remove(rule);
    }
View Full Code Here

                        // I have no paths to resolve the resolve value
                        if (inputPaths.isEmpty()) {
                            // if there are no more unresolved vars, I add a path with only the resolve himself
                            if (_finder.find(resolveNode._resolve.getValue()).isEmpty()) {
                                // If I have valitors, I must resolve them
                                Rule parent = resolveNode._resolve.getParent();
                                if (parent != null && !parent.getValidators().isEmpty()) {
                                    PathCollection validatorsPaths = getValidatorsPaths(parent);
                                    // if I can resolve validators
                                    if (!validatorsPaths.isEmpty()) {
                                        validatorsPaths.addToAll(new PathEntry(varExpNode._varExpression, resolveNode._resolve));
                                        varExtPaths.addAll(validatorsPaths);
                                    }
                                } else {
                                    varExtPaths.addSingle(new PathEntry(varExpNode._varExpression, resolveNode._resolve));
                                }
                            }
//                            varExtPaths.addSingle(new PathEntry(varExpNode._varExpression, resolveNode._resolve));
                        } else {
                            // for each path which resolves the resolve value I add the resolve himself (as first)
                            // then add all to the main var expression paths
                            inputPaths.prependToAll(new PathEntry(varExpNode._varExpression, resolveNode._resolve));
                           
                            Rule parent = resolveNode._resolve.getParent();
                            // If I have valitors, I must resolve them
                            if (parent != null && !parent.getValidators().isEmpty()) {
                                PathCollection validatorsPaths = getValidatorsPaths(parent);
                                // if I can resolve validators
                                if (!validatorsPaths.isEmpty()) {
                                    validatorsPaths.addToAll(new PathEntry(varExpNode._varExpression, resolveNode._resolve));
                                    varExtPaths.addAll(inputPaths.multiply(validatorsPaths));
View Full Code Here

                ruleName = ruleMatcher.group(1);
                if (ruleMatcher.group(2) != null) {
                    categories.addAll(Arrays.asList(ruleMatcher.group(2).split(
                            ",")));
                }
                Rule rule = _repo.getRule(ruleName);
                if (rule == null) {
                    throw new IllegalArgumentException("Cannot find rule \"" + ruleName + "\"");
                }
                Var var = rule.getVar(varName);
                if (var == null) {
                    throw new IllegalArgumentException("Cannot find var \"" + varName + "\" for rule \"" + ruleName + "\"");
                }
                vars.add(new VarExpression(rule, categories.isEmpty() ? null : Utils.getCategories(categories), var));
            } else {
View Full Code Here

TOP

Related Classes of net.sourceforge.temply.base.rules.Rule

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.