Package org.antlr.stringtemplate

Examples of org.antlr.stringtemplate.StringTemplateGroup


            return name;
        }
        final StringTokenizer tok = new StringTokenizer(name, ":");
        final String group_name = tok.nextToken();
        final String template_name = tok.nextToken();
        final StringTemplateGroup group = loader.loadGroup(group_name);
        final StringTemplate template = group.getInstanceOf(template_name);
        template.setAttributes(ctx.getAttributes());
        return template.toString();
    }
View Full Code Here


        final BufferedReader br = locate(groupName + ".stg");
        if (br == null) {
            errors.error("no such group file " + groupName + ".stg", null);
            return null;
        }
        final StringTemplateGroup group = new StringTemplateGroup(br, lexerClass, errors);
        groupCache.putIfAbsent(groupName, group);

        return group;
    }
View Full Code Here

        final BufferedReader br = locate(groupName + ".stg");
        if (br == null) {
            errors.error("no such group file " + groupName + ".stg", null);
            return null;
        }
        final StringTemplateGroup group = new StringTemplateGroup(br, lexerClass, errors, superGroup);
        groupCache.putIfAbsent(key, group);

        return group;
    }
View Full Code Here

        List<AMQPClass> classes = bindClasses(nav);

        writeConstants(nav);
       
        InputStream template = readInputFile("AMQP_Method.as.stg");
        StringTemplateGroup templates = new StringTemplateGroup(new InputStreamReader(template), AngleBracketTemplateLexer.class);

        for (AMQPClass clazz : classes) {
            for (Method method : clazz.getMethods()) {
                StringTemplate initiatingClass = templates.getInstanceOf("class");
                initiatingClass.setAttribute("method", method);
                String base = methodsDir + "/" + method.getAmqpClass().getName();
                writeFile(base, method.getName(), initiatingClass.toString());

                if (method.isSynchronous() && method.getResponse() != null) {
                    StringTemplate responseClass = templates.getInstanceOf("class");
                    responseClass.setAttribute("method", method.getResponse());
                    writeFile(base, method.getResponse().getName(), responseClass.toString());
                }
            }

            StringTemplate fieldPropertiesClass = templates.getInstanceOf("headerclass");
            fieldPropertiesClass.setAttribute("amqpclass", clazz);
            writeFile(headerDir, clazz.getCamelCaseName() + "Properties", fieldPropertiesClass.toString());

        }
View Full Code Here

    }

    private static void writeConstants(VTDNav nav) throws Exception {
        List<Constant> constants = bindConstants(nav);
        InputStream is = readInputFile("AMQP_Constants.as.stg");
        StringTemplateGroup constantsGroup = new StringTemplateGroup(new InputStreamReader(is), AngleBracketTemplateLexer.class);
        StringTemplate constantsClass = constantsGroup.getInstanceOf("class");
        constantsClass.setAttribute("constants", constants);
        writeFile(baseDir, "AMQP", constantsClass.toString());
    }
View Full Code Here

        writeFile(baseDir, "AMQP", constantsClass.toString());
    }

    private static void generateMethodReader(String template, List<AMQPClass> classes, String dir, String className) throws IOException {
        InputStream inputStream = readInputFile(template);
        StringTemplateGroup templateGroup = new StringTemplateGroup(new InputStreamReader(inputStream), AngleBracketTemplateLexer.class);
        StringTemplate readerClass = templateGroup.getInstanceOf("class");
        readerClass.setAttribute("amqpclasses", classes);
        writeFile(dir, className, readerClass.toString());
    }
View Full Code Here

    }
  }

  protected Configuration loadFOPConfig() throws MojoExecutionException {
          String fontPath  = (null != localFontPath && localFontPath != "") ? localFontPath : (new File(getAutopdfTargetDirectory().getParentFile(), "fonts")).getAbsolutePath();
    StringTemplateGroup templateGroup = new StringTemplateGroup("fonts", fontPath);
    StringTemplate template = templateGroup.getInstanceOf("fontconfig");
    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
    template.setAttribute ("fontPath",fontPath);
    final String config = template.toString();
    if (getLog().isDebugEnabled()) {
      getLog().debug(config);
View Full Code Here

    }

    protected Configuration loadFOPConfig() throws MojoExecutionException {
        System.out.println ("At load config");
        String fontPath = (null != localFontPath && localFontPath != "")? localFontPath: (new File(getTargetDirectory().getParentFile(), "fonts")).getAbsolutePath();
        StringTemplateGroup templateGroup = new StringTemplateGroup("fonts", fontPath);
        StringTemplate template = templateGroup.getInstanceOf("fontconfig");
        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
        template.setAttribute ("fontPath",fontPath);
        final String config = template.toString();
        if (getLog().isDebugEnabled()) {
            getLog().debug(config);
View Full Code Here

  public static void genSQL(Class<?> c, LinkedList<member> members) throws SecurityException,
      NoSuchFieldException, IOException {
    suffix = ".sql";
    groupFile = stgPath + "Sql.stg";
    FileReader fr = new FileReader(groupFile);
    StringTemplateGroup templates = new StringTemplateGroup(fr);
    fr.close();
    templates.registerRenderer(Class.class, new TypeRenderer());
    PrintWriter outfile = new PrintWriter(new File(outPutPath
        + c.getSimpleName() + suffix));
    for (member m : members) {
      StringTemplate classST = templates.getInstanceOf("output");
      classST.setAttribute("class", m.cls);
      classST.setAttribute("fields", m.fields);
      classST.setAttribute("arrayFields", m.arrayFields);
      classST.setAttribute("methodFields", m.methodFields);
      outfile.print(classST);
View Full Code Here

  public static void genJAVA(Class<?> c, LinkedList<member> members) throws SecurityException,
      NoSuchFieldException, IOException {
    suffix = ".java";
    groupFile = stgPath + "JavaModel.stg";
    FileReader fr = new FileReader(groupFile);
    StringTemplateGroup templates = new StringTemplateGroup(fr);
    fr.close();
    templates.registerRenderer(Class.class, new TypeRenderer());
    for (member m : members) {
      PrintWriter outfile = new PrintWriter(new File(outPutPath
          + m.cls.simpleName + suffix));
      StringTemplate classST = templates.getInstanceOf("output");
      classST.setAttribute("class", m.cls);
      classST.setAttribute("fields", m.fields);
      classST.setAttribute("arrayFields", m.arrayFields);
      classST.setAttribute("methodFields", m.methodFields);
      classST.setAttribute("interfaceImps", m.interfaceImps);
      outfile.print(classST);
      outfile.flush();
      outfile.close();
    }
    groupFile = stgPath + "Java.stg";
    fr = new FileReader(groupFile);
    templates = new StringTemplateGroup(fr);
    fr.close();
    for (member m : members) {
      if (!m.cls.isInterface) {
        PrintWriter outfile = new PrintWriter(new File(outPutPath
            + m.cls.simpleName + "IO" + suffix));
        StringTemplate classST = templates.getInstanceOf("output");
        classST.setAttribute("class", m.cls);
        classST.setAttribute("fields", m.fields);
        classST.setAttribute("arrayFields", m.arrayFields);
        classST.setAttribute("methodFields", m.methodFields);
        outfile.print(classST);
View Full Code Here

TOP

Related Classes of org.antlr.stringtemplate.StringTemplateGroup

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.