Package xdoclet.template

Examples of xdoclet.template.TemplateParser


            else {
                if (getDocletContext().getActiveSubTask().getMergeDir() != null) {
                    File mergeFile = new File(getDocletContext().getActiveSubTask().getMergeDir(), mergeFilePattern);

                    if (getEngine() instanceof TemplateParser) {
                        TemplateParser parser = (TemplateParser) getEngine();

                        // This avoids infinite loop when a merge file merge itself
                        if (parser.hasMergeFile(mergeFilePattern)) {
                            return null;
                        }
                        else {
                            parser.addMergeFile(mergeFilePattern);
                        }
                    }

                    if (mergeFile.exists()) {
                        log.debug("Merge file found in " + getDocletContext().getActiveSubTask().getMergeDir());
                        file = FileManager.getURLContent(mergeFile.toURL());
                    }
                    else {
                        // Backwards Compatibility - check for templates still using .j file extensions
                        if (mergeFilePattern.endsWith(".xdt")) {
                            mergeFile = new File(getDocletContext().getActiveSubTask().getMergeDir(),
                                mergeFilePattern.substring(0, mergeFilePattern.length() - 4) + ".j");
                            log.debug(".xdt mergefile not found, trying " + mergeFile.getName());

                            if (mergeFile.exists()) {
                                log.debug("Merge file found in " + getDocletContext().getActiveSubTask().getMergeDir());
                                file = FileManager.getURLContent(mergeFile.toURL());
                            }
                            else {
                                log.debug("Merge file NOT found in " + getDocletContext().getActiveSubTask().getMergeDir());
                            }
                        }
                        else {
                            log.debug("Merge file NOT found in " + getDocletContext().getActiveSubTask().getMergeDir());
                        }
                    }
                }
            }
            if (file != null)
                return file;

            // was not found in mergedir, try the jar
            URL jarResource = getClass().getResource('/' + mergeFilePattern);

            if (jarResource != null) {
                log.debug("Merge file found in jar");

                if (getEngine() instanceof TemplateParser) {
                    TemplateParser parser = (TemplateParser) getEngine();

                    // This avoids infinite loop when a merge file merge itself
                    if (parser.hasMergeFile(mergeFilePattern)) {
                        return null;
                    }
                    else {
                        parser.addMergeFile(mergeFilePattern);
                    }
                }

                file = FileManager.getURLContent(jarResource);
            }
View Full Code Here


        // 2. Check timestamp of Merge files found inside Template
        String[] files;

        if (getParserDb().get(templateFile) == null) {
            TemplateEngine the_engine = subTask.getEngine();
            TemplateParser the_parser = TemplateParser.getParserInstance();

            subTask.setEngine(the_parser);

            // Why is setOutput called here? We're only checking _IF_ we're going to generate! (Aslak)
            the_parser.setOutput(file);
            the_parser.setTemplateURL(templateURL);

            try {
                the_parser.start();
            }
            catch (TemplateException e) {
                throw new XDocletException(e, e.toString());
            }

            files = the_parser.getMergeFiles();
            if (files != null) {
                updateParserDb(templateURL, files);
            }

            //restore
View Full Code Here

TOP

Related Classes of xdoclet.template.TemplateParser

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.