Class CodeWriter

java.lang.Object
com.sun.codemodel.CodeWriter
Direct Known Subclasses:
FileCodeWriter, FilerCodeWriter, FilterCodeWriter, OutputStreamCodeWriter, SingleStreamCodeWriter, ZipCodeWriter

public abstract class CodeWriter extends Object
Receives generated code and writes to the appropriate storage.
Author:
Kohsuke Kawaguchi ([email protected])
  • Field Details

    • encoding

      protected String encoding
      Encoding to be used by the writer. Null means platform specific encoding.
      Since:
      2.5
  • Constructor Details

    • CodeWriter

      public CodeWriter()
  • Method Details

    • openBinary

      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 - The package of the file to be written.
      fileName - File name without the path. Something like "Foo.java" or "Bar.properties"
      Throws:
      IOException
    • openSource

      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 - The package of the file to be written.
      fileName - File name without the path. Something like "Foo.java" or "Bar.properties"
      Throws:
      IOException
    • close

      public abstract void close() throws IOException
      Called by CodeModel at the end of the process.
      Throws:
      IOException