FileDocCategorySizeDatePackage
JavaFileWriter.javaAPI DocGlassfish v2 API4616Fri May 04 22:35:22 BST 2007com.sun.jdo.spi.persistence.utility.generator

JavaFileWriter

public interface JavaFileWriter
This interface can be used to describe a java source file. The resulting source definition can be viewed by calling {@link java.lang.Object#toString} or saved to a file by calling {@link #save}. The semantics of this interface are as follows: - Resource allocation is deferred to save - there is no need to worry about resource cleanup if an IOException is thrown from other methods (addImport, setPackage, addClass). - Any implementation of this interface must handle the closing of resources during save if an exception is thrown.

Use this interface in conjunction with one or more {@link JavaClassWriter} instances to describe the class(es) in a java file.

author
raccah

Fields Summary
Constructors Summary
Methods Summary
public voidaddClass(JavaClassWriter classWriter)
Adds a class to this source file.

param
classWriter The definition of the class.
throws
IOException If the class information cannot be added.

public voidaddImport(java.lang.String importName, java.lang.String[] comments)
Adds an import statement for this source file.

param
importName Name of the class or package (including the *) to be imported. This string should not contain "import" or the ;
param
comments The comments shown just above the import statement. The comments are passed as an array so the line separators can be added by the implementation. Note that not all implementations will choose to make use of this comment.
throws
IOException If the import information cannot be added.

public voidsave()
Saves the file by writing out the source contents to whatever file (or alternate representation) was specified (usually by the constructor of the implementation class.

throws
IOException If the file cannot be saved.

public voidsetPackage(java.lang.String packageName, java.lang.String[] comments)
Sets the package for this file. Note that the package name format must be package style (that is - it can contain . but not / or $).

param
packageName The name of the package for this source file.
param
comments The comments shown just above the package statement. The comments are passed as an array so the line separators can be added by the implementation. Note that not all implementations will choose to make use of this comment.
throws
IOException If the package cannot be set.