Top Description Fields Constructors Methods
com.sun.codemodel.writer

public Class FileCodeWriter

extends CodeWriter
Class Inheritance
Imports
java.io.File, .FileOutputStream, .IOException, .OutputStream, java.util.HashSet, .Set, com.sun.codemodel.CodeWriter, .JPackage

Writes all the source files under the specified file folder.
Author
Kohsuke Kawaguchi ([email protected])

Field Summary

Modifier and TypeField and Description
private final boolean
readOnly

specify whether or not to mark the generated files read-only

private final Set<File>
readonlyFiles

Files that shall be marked as read only.

private final File
target

The target directory to put source code.

Inherited from com.sun.codemodel.CodeWriter:
encoding

Constructor Summary

AccessConstructor and Description
public
public
FileCodeWriter(File target, String encoding)

public
FileCodeWriter(File target, boolean readOnly)

public
FileCodeWriter(File target, boolean readOnly, String encoding)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract com.sun.codemodel.CodeWriter.close.

Called by CodeModel at the end of the process.

protected File
getFile(JPackage pkg, String fileName)

public OutputStream
openBinary(JPackage pkg, String fileName)

Implements abstract com.sun.codemodel.CodeWriter.openBinary.

Called by CodeModel to store the specified file.

private static String
toDirName(JPackage pkg)

Converts a package name to the directory name.

Inherited from com.sun.codemodel.CodeWriter:
openSource

Field Detail

readOnlyback to summary
private final boolean readOnly

specify whether or not to mark the generated files read-only

readonlyFilesback to summary
private final Set<File> readonlyFiles

Files that shall be marked as read only.

targetback to summary
private final File target

The target directory to put source code.

Constructor Detail

FileCodeWriterback to summary
public FileCodeWriter(File target) throws IOException
FileCodeWriterback to summary
public FileCodeWriter(File target, String encoding) throws IOException
FileCodeWriterback to summary
public FileCodeWriter(File target, boolean readOnly) throws IOException
FileCodeWriterback to summary
public FileCodeWriter(File target, boolean readOnly, String encoding) throws IOException

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract com.sun.codemodel.CodeWriter.close.

Doc from com.sun.codemodel.CodeWriter.close.

Called by CodeModel at the end of the process.

Annotations
@Override
getFileback to summary
protected File getFile(JPackage pkg, String fileName) throws IOException
openBinaryback to summary
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException

Implements abstract com.sun.codemodel.CodeWriter.openBinary.

Doc from com.sun.codemodel.CodeWriter.openBinary.

Called by CodeModel to store the specified file. The callee must allocate a storage to store the specified file.

The returned stream will be closed before the next file is stored. So the callee can assume that only one OutputStream is active at any given time.

Annotations
@Override
toDirNameback to summary
private static String toDirName(JPackage pkg)

Converts a package name to the directory name.