Package org.rythmengine.exception

Examples of org.rythmengine.exception.ParseException


    private String initCode = null;

    public void setInitCode(String code) {
        if (null != initCode)
            throw new ParseException(engine, templateClass, parser.currentLine(), "@init section already declared.");
        initCode = code;
    }
View Full Code Here


    public InlineTag defTag(String tagName, String retType, String signature, String body) {
        tagName = tagName.trim();
        InlineTag tag = new InlineTag(tagName, retType, signature, body);
        if (inlineTags.contains(tag)) {
            throw new ParseException(engine, templateClass, parser.currentLine(), "inline tag already defined: %s", tagName);
        }
        inlineTags.add(tag);
        inlineTagBodies.push(builders);
        builders = tag.builders;
        if ("void".equals(tag.retType)) {
View Full Code Here

        return tag;
    }

    public void endTag(InlineTag tag) {
        if (inlineTagBodies.empty())
            throw new ParseException(engine, templateClass, parser.currentLine(), "Unexpected tag definition close");
        if (tag.autoRet) {
            builders.add(new CodeToken("String __s = toString();this.setSelfOut(__sb);return s().raw(__s);", parser));
        }
        builders = inlineTagBodies.pop();
    }
View Full Code Here

    }

    public String addInclude(String include, int lineNo) {
        String tmplName = engine.testTemplate(include, templateClass);
        if (null == tmplName) {
            throw new ParseException(engine, templateClass, lineNo, "include template not found: %s", include);
        }
        TemplateBase includeTmpl = (TemplateBase) engine.getRegisteredTemplate(tmplName);
        if (includeTmpl instanceof JavaTagBase) {
            throw new ParseException(engine, templateClass, lineNo, "cannot include Java tag: %s", include);
        }
        TemplateClass includeTc = includeTmpl.__getTemplateClass(false);
        includeTc.buildSourceCode(includingClassName());
        merge(includeTc.codeBuilder);
        templateClass.addIncludeTemplateClass(includeTc);
View Full Code Here

        this.extended = c.getName();
    }

    public void setExtended(String extended, InvokeTemplateParser.ParameterDeclarationList args, int lineNo) {
        if (simpleTemplate()) {
            throw new ParseException(engine, templateClass, lineNo, "Simple template does not allow to extend layout template");
        }
        if (null != this.extended) {
            throw new ParseException(engine, templateClass, lineNo, "Extended template already declared");
        }
        String fullName = engine.testTemplate(extended, templateClass);
        if (null == fullName) {
            // try legacy style
            setExtended_deprecated(extended, args, lineNo);
View Full Code Here

                ITemplateResource resource = engine.resourceManager().getResource(origin);
                if (resource.isValid()) tc = new TemplateClass(resource, engine);
            }
        }
        if (null == tc) {
            throw new ParseException(engine, templateClass, lineNo, "Cannot find extended template by name \"%s\"", origin);
        }
        this.extended = tc.name();
        this.extendedTemplateClass = tc;
        this.templateClass.extendedTemplateClass = tc;
        this.engine.addExtendRelationship(tc, this.templateClass);
View Full Code Here

    private Map<String, List<Token>> macros = new HashMap<String, List<Token>>();
    private Stack<String> macroStack = new Stack<String>();

    public void pushMacro(String macro) {
        if (macros.containsKey(macro)) {
            throw new ParseException(engine, templateClass, parser.currentLine(), "Macro already defined: %s", macro);
        }
        macroStack.push(macro);
        macros.put(macro, new ArrayList<Token>());
    }
View Full Code Here

        macros.put(macro, new ArrayList<Token>());
    }

    public void popMacro() {
        if (macroStack.empty()) {
            throw new ParseException(engine, templateClass, parser.currentLine(), "no macro found in stack");
        }
        macroStack.pop();
    }
View Full Code Here

    }

    @Override
    public String closeBlock() throws ParseException {
        if (blocks.isEmpty())
            throw new ParseException(getEngine(), cb.getTemplateClass(), currentLine(), "No open block found");
        IBlockHandler bh = blocks.pop();
        return null == bh ? "" : bh.closeBlock();
    }
View Full Code Here

                        r = new Regex("([a-zA-Z0-9\\[\\]_]+(?@<>)?)\\s*\\,\\s*([a-zA-Z0-9\\[\\]_]+(?@<>)?)");
                        if (r.search(this.type)) {
                            if (key) this.type = r.stringMatched(1);
                            else this.type = r.stringMatched(2);
                        } else {
                            throw new ParseException(ctx.getEngine(), ctx.getTemplateClass(), line, "Invalid for loop iterator type declaration: %s", itrType);
                        }
                    }
                } else {
                    if (itrType.endsWith("]")) {
                        int pos = itrType.lastIndexOf("[");
View Full Code Here

TOP

Related Classes of org.rythmengine.exception.ParseException

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.