Top Description Fields Constructors Methods
com.sun.codemodel

public abstract Class CodeWriter

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.codemodel.writer.FileCodeWriter, com.sun.codemodel.writer.FilterCodeWriter, com.sun.codemodel.writer.OutputStreamCodeWriter, com.sun.codemodel.writer.SingleStreamCodeWriter, com.sun.codemodel.writer.ZipCodeWriter
Imports
java.io.IOException, .OutputStream, .OutputStreamWriter, .Writer, java.nio.charset.CharsetEncoder, com.sun.codemodel.util.EncoderFactory, .UnicodeEscapeWriter

Receives generated code and writes to the appropriate storage.
Author
Kohsuke Kawaguchi ([email protected])

Field Summary

Modifier and TypeField and Description
protected String
encoding

Encoding to be used by the writer.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract void
close()

Called by CodeModel at the end of the process.

public abstract OutputStream
openBinary(JPackage
The package of the file to be written.
pkg
,
String
File name without the path. Something like "Foo.java" or "Bar.properties"
fileName
)

Called by CodeModel to store the specified file.

public Writer
openSource(JPackage
The package of the file to be written.
pkg
,
String
File name without the path. Something like "Foo.java" or "Bar.properties"
fileName
)

Called by CodeModel to store the specified file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

encodingback to summary
protected String encoding

Encoding to be used by the writer. Null means platform specific encoding.

Since
2.5

Constructor Detail

CodeWriterback to summary
public CodeWriter()

Method Detail

closeback to summary
public abstract void close() throws IOException

Called by CodeModel at the end of the process.

openBinaryback to summary
public abstract OutputStream openBinary(JPackage pkg, String fileName) throws IOException

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.

Parameters
pkg:JPackage

The package of the file to be written.

fileName:String

File name without the path. Something like "Foo.java" or "Bar.properties"

openSourceback to summary
public Writer openSource(JPackage pkg, String fileName) throws IOException

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.

Parameters
pkg:JPackage

The package of the file to be written.

fileName:String

File name without the path. Something like "Foo.java" or "Bar.properties"