Package javax.tools

Examples of javax.tools.JavaFileObject.openWriter()


    for (TableObject tableObject : tableObjectCache.values()) {
      logger.d("Writing for " + tableObject.getTableName());
      Element element = tableObject.getOriginatingElement();
      try {
        JavaFileObject jfo = filer.createSourceFile(tableObject.getFqcn(), element);
        Writer writer = jfo.openWriter();
        tableObject.brewJava(writer);
        writer.flush();
        writer.close();
      } catch (IOException e) {
        logger.e(String.format(
View Full Code Here


        JavaFileObject sourceFile = filer.createSourceFile(generatedClassName);

        StephenerializationPreprocessorFieldGenerator generator = new StephenerializationPreprocessorFieldGenerator();
        Set<StephenerializationPreprocessorField> fields = generator.generateFields(element);

        PreprocessingWriter w = new PreprocessingWriter(sourceFile.openWriter());

        writePackageImportsAndClass(w, element, simpleGeneratedClassName);

        w.indent();
        writeWriteMethod(w, className, fields, stephenerializable);
View Full Code Here

                                               null);
        if (inputFiles.contains(outFile)) {
            log.error(cdef.pos(), "source.cant.overwrite.input.file", outFile);
            return null;
        } else {
            BufferedWriter out = new BufferedWriter(outFile.openWriter());
            try {
                new Pretty(out, true).printUnit(env.toplevel, cdef);
                if (verbose)
                    log.printVerbose("wrote.file", outFile);
            } finally {
View Full Code Here

        String className = fm.inferBinaryName(StandardLocation.SOURCE_PATH, tree.getSourceFile());
        JavaFileObject fo = fm.getJavaFileForOutput(StandardLocation.SOURCE_OUTPUT,
                className, JavaFileObject.Kind.SOURCE, null);
        // System.err.println("Writing " + className + " to " + fo.getName());
        Writer out = fo.openWriter();
        try {
            new Pretty(out, true).printExpr((JCTree) tree3);
        } finally {
            out.close();
        }
View Full Code Here

      return null;
    }

    try {
      JavaFileObject obj = state.filer.createSourceFile(packageName + "." + simpleName, x);
      Writer w = obj.openWriter();
      w.write(sb.toString());
      w.close();
    } catch (Exception e) {
      StringWriter sw = new StringWriter();
      e.printStackTrace(new PrintWriter(sw));
View Full Code Here

                                               null);
        if (inputFiles.contains(outFile)) {
            log.error(cdef.pos(), "source.cant.overwrite.input.file", outFile);
            return null;
        } else {
            BufferedWriter out = new BufferedWriter(outFile.openWriter());
            try {
                new Pretty(out, true).printUnit(env.toplevel, cdef);
                if (verbose)
                    printVerbose("wrote.file", outFile);
            } finally {
View Full Code Here

        String qualifiedBuilderName = qualifiedFragmentName + "Builder";

        Element[] orig = originating.toArray(new Element[originating.size()]);
        origHelper = orig;
        JavaFileObject jfo = filer.createSourceFile(qualifiedBuilderName, orig);
        Writer writer = jfo.openWriter();
        JavaWriter jw = new JavaWriter(writer);
        writePackage(jw, entry.getKey());
        jw.emitImports("android.os.Bundle");
        jw.beginType(builder, "class", EnumSet.of(Modifier.PUBLIC, Modifier.FINAL));
        jw.emitField("Bundle", "mArguments", EnumSet.of(Modifier.PRIVATE, Modifier.FINAL),
View Full Code Here

  private void writeAutoMapping(Map<String, String> mapping, Element[] element) {

    try {
      JavaFileObject jfo =
          filer.createSourceFile(FragmentArgs.AUTO_MAPPING_QUALIFIED_CLASS, element);
      Writer writer = jfo.openWriter();
      JavaWriter jw = new JavaWriter(writer);
      // Package
      jw.emitPackage(FragmentArgs.AUTO_MAPPING_PACKAGE);
      // Imports
      jw.emitImports("android.os.Bundle");
View Full Code Here

  private void writeSourceFile(String className, String text, TypeElement originatingType) {
    try {
      JavaFileObject sourceFile =
          processingEnv.getFiler().createSourceFile(className, originatingType);
      Writer writer = sourceFile.openWriter();
      try {
        writer.write(text);
      } finally {
        writer.close();
      }
View Full Code Here

  private void writeSourceFile(String className, String text, TypeElement originatingType) {
    try {
      JavaFileObject sourceFile =
          processingEnv.getFiler().createSourceFile(className, originatingType);
      Writer writer = sourceFile.openWriter();
      try {
        writer.write(text);
      } finally {
        writer.close();
      }
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.