Package javax.tools

Examples of javax.tools.JavaFileObject.openWriter()


    //
    Writer writer = null;
    try {
      JavaFileObject applicationFile = env.createSourceFile(fqn, elt);
      writer = applicationFile.openWriter();

      writer.append("package ").append(fqn.getParent()).append(";\n");

      // Imports
      writer.append("import ").append(ApplicationDescriptor.class.getCanonicalName()).append(";\n");
View Full Code Here


      }
      Name clazz = pkg.getPackageName().append(simpleName);
      Writer writer = null;
      try {
        JavaFileObject file = metaModel.processingContext.createSourceFile(clazz, pkgElt);
        writer = file.openWriter();
        writer.append("package ").append(pkg.getPackageName()).append(";\n");
        writer.append("import javax.servlet.annotation.WebServlet;\n");
        writer.append("import javax.servlet.annotation.WebInitParam;\n");
        writer.append("@WebServlet(name=\"").append(simpleName).append("\",urlPatterns=\"").append(urlPattern).append("\"");
        if (resourceBundle != null) {
View Full Code Here

    String[] names) throws ProcessingException {
    Writer writer = null;
    Name fqn = Name.parse(pkgElt.getQualifiedName()).append(names[0]);
    try {
      JavaFileObject file = env.createSourceFile(fqn, pkgElt);
      writer = file.openWriter();

      //
      writer.append("package ").append(pkgElt.getQualifiedName()).append(";\n");
      writer.append("import ").append(Generated.class.getCanonicalName()).append(";\n");
      writer.append("@Generated(value={})\n");
View Full Code Here

      //
      if (!done) {
        try {
          Filer filer = processingEnv.getFiler();
          JavaFileObject b = filer.createSourceFile("compiler.processor.B");
          PrintWriter writer = new PrintWriter(b.openWriter());
          writer.println("package compiler.processor; public class B { }");
          writer.close();
          done = true;
        }
        catch (IOException e) {
View Full Code Here

            String qualifiedCanonicalName = persistenceUnit.getQualifiedCanonicalName(qualifiedName);
            String canonicalName = getName(qualifiedCanonicalName);
            String canonicalpackage = getPackage(qualifiedCanonicalName);
           
            JavaFileObject file = processingEnv.getFiler().createSourceFile(qualifiedCanonicalName, element);
            writer = file.openWriter();
           
            // Print the package if we have one.
            if (! canonicalpackage.equals("")) {
                writer.append("package " + canonicalpackage + ";\n\n");
            }
View Full Code Here

    @Override
    public synchronized void init(ProcessingEnvironment processingEnv) {
      try {
        JavaFileObject sourceFile = processingEnv.getFiler().createSourceFile(GENERATED_CLASS_NAME);
        Writer writer = sourceFile.openWriter();
        writer.write(GENERATED_SOURCE);
        writer.close();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
View Full Code Here

 
  private void generateSourceFile(Element originatingElement, String className, String extending, List<String> implementing, List<FieldData> fields,
      List<ExecutableElement> methodsToCopy, Relations relations) throws IOException {
   
    JavaFileObject file = processingEnv.getFiler().createSourceFile(className, originatingElement);
    Writer out = file.openWriter();
    out.write("//Generated by lombok.ast.template.TemplateProcessor. DO NOT EDIT, DO NOT CHECK IN!\n\n");
   
    String pkgName, typeName; {
      int idx = className.lastIndexOf('.');
      if (idx == -1) {
View Full Code Here

            try {
                final Filer filer = processingEnv.getFiler();
                final JavaFileObject file = filer.createSourceFile(type.getName().getQualified());

                try (Writer writer = file.openWriter()) {
                    mustache.execute(writer, type).flush();
                }
            } catch (IOException e) {
                throw new IllegalArgumentException(e);
            }
View Full Code Here

    }
  }
 
  private void finish0() throws IOException {
    JavaFileObject file = env.getFiler().createSourceFile("lombok.ast.syntaxChecks.SyntacticValidityVisitor");
    Writer out = file.openWriter();
    out.write("//Generated by SyntaxValidityCheckerGenerator. DO NOT EDIT, DO NOT CHECK IN!\n\n");
   
    out.write("package lombok.ast.syntaxChecks;\n\n");
    out.write("import lombok.ast.*;\n\n");
    out.write("/**\n");
 
View Full Code Here

        messager.printMessage(Kind.NOTE, "Class: " + className);
        try {
          // now write the new class which will be compiled in the
          // same run
          JavaFileObject sourceFile = processingEnv.getFiler().createSourceFile(className, element);
          Writer writer = sourceFile.openWriter();
          writer.append("package " + elementPackage.getQualifiedName() + ";\n\n");
          writer.append("import javax.annotation.Generated;\n\n");
          writer.append("@Generated(\"" + getClass().getCanonicalName() + "\")\n");
          writer.append("public class " + name + "_Doc {\n");
          writer.append(" public String getDoc(){\n");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.