Package org.jboss.jdeparser
Class JFiler
- java.lang.Object
-
- org.jboss.jdeparser.JFiler
-
public abstract class JFiler extends java.lang.Object
A file manager for writing out source files.- Author:
- David M. Lloyd
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
JFiler()
Construct a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
getEncoding()
Get the file encoding to use.static JFiler
newInstance(java.io.File target)
Get an instance which writes to the filesystem.static JFiler
newInstance(javax.annotation.processing.Filer filer)
Get an instance which uses an underlyingFiler
.abstract java.io.OutputStream
openStream(java.lang.String packageName, java.lang.String fileName)
Open an output stream for writing the given file.java.io.Writer
openWriter(java.lang.String packageName, java.lang.String fileName)
Open a writer for the given file.void
setEncoding(java.lang.String encoding)
Set the file encoding to use.
-
-
-
Method Detail
-
newInstance
public static JFiler newInstance(javax.annotation.processing.Filer filer)
Get an instance which uses an underlyingFiler
.- Parameters:
filer
- the annotation processing filer- Returns:
- the JDeparser filer
-
newInstance
public static JFiler newInstance(java.io.File target)
Get an instance which writes to the filesystem.- Parameters:
target
- the target source path- Returns:
- the JDeparser filer
-
getEncoding
public java.lang.String getEncoding()
Get the file encoding to use.- Returns:
- the file encoding
-
setEncoding
public void setEncoding(java.lang.String encoding)
Set the file encoding to use.- Parameters:
encoding
- the file encoding
-
openStream
public abstract java.io.OutputStream openStream(java.lang.String packageName, java.lang.String fileName) throws java.io.IOException
Open an output stream for writing the given file.- Parameters:
packageName
- the package namefileName
- the file name- Returns:
- the output stream
- Throws:
java.io.IOException
- if an error occurs during write
-
openWriter
public java.io.Writer openWriter(java.lang.String packageName, java.lang.String fileName) throws java.io.IOException
Open a writer for the given file. The default implementation callsopenStream(String, String)
and wraps the result with anOutputStreamWriter
using the configured file encoding.- Parameters:
packageName
- the package namefileName
- the file name- Returns:
- the writer
- Throws:
java.io.IOException
- if an error occurs during write
-
-