Class JFiler

java.lang.Object
org.jboss.jdeparser.JFiler

public abstract class JFiler extends Object
A file manager for writing out source files.
Author:
David M. Lloyd
  • Constructor Details

    • JFiler

      protected JFiler()
      Construct a new instance.
  • Method Details

    • newInstance

      public static JFiler newInstance(Filer filer)
      Get an instance which uses an underlying Filer.
      Parameters:
      filer - the annotation processing filer
      Returns:
      the JDeparser filer
    • newInstance

      public static JFiler newInstance(File target)
      Get an instance which writes to the filesystem.
      Parameters:
      target - the target source path
      Returns:
      the JDeparser filer
    • getEncoding

      public String getEncoding()
      Get the file encoding to use.
      Returns:
      the file encoding
    • setEncoding

      public void setEncoding(String encoding)
      Set the file encoding to use.
      Parameters:
      encoding - the file encoding
    • openStream

      public abstract OutputStream openStream(String packageName, String fileName) throws IOException
      Open an output stream for writing the given file.
      Parameters:
      packageName - the package name
      fileName - the file name
      Returns:
      the output stream
      Throws:
      IOException - if an error occurs during write
    • openWriter

      public Writer openWriter(String packageName, String fileName) throws IOException
      Open a writer for the given file. The default implementation calls openStream(String, String) and wraps the result with an OutputStreamWriter using the configured file encoding.
      Parameters:
      packageName - the package name
      fileName - the file name
      Returns:
      the writer
      Throws:
      IOException - if an error occurs during write