Class IOJavaFileWriter
- java.lang.Object
-
- com.sun.jdo.spi.persistence.utility.generator.io.IOJavaFileWriter
-
- All Implemented Interfaces:
JavaFileWriter
public class IOJavaFileWriter extends Object implements JavaFileWriter
This implementation of theJavaFileWriterinterface is based onFileand simpleStringBuffer"println" type statements.Use this interface in conjunction with one or more
JavaClassWriterinstances to describe the class(es) in a java file.- Author:
- raccah
-
-
Constructor Summary
Constructors Constructor Description IOJavaFileWriter(File file)Creates a new instance of IOJavaFileWriter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddClass(JavaClassWriter classWriter)Adds a class to this source file.voidaddImport(String importName, String[] comments)Adds an import statement for this source file.protected static ResourceBundlegetMessages()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.voidsetPackage(String packageName, String[] comments)Sets the package for this file.StringtoString()Returns a string representation of this object.
-
-
-
Constructor Detail
-
IOJavaFileWriter
public IOJavaFileWriter(File file)
Creates a new instance of IOJavaFileWriter.- Parameters:
file- The file object which will be used at save time.
-
-
Method Detail
-
getMessages
protected static final ResourceBundle getMessages()
- Returns:
- I18N message handler for this element
-
setPackage
public void setPackage(String packageName, 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 $).- Specified by:
setPackagein interfaceJavaFileWriter- Parameters:
packageName- The name of the package for this source file.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.
-
addImport
public void addImport(String importName, String[] comments)
Adds an import statement for this source file.- Specified by:
addImportin interfaceJavaFileWriter- Parameters:
importName- Name of the class or package (including the *) to be imported. This string should not contain "import" or the ;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.
-
addClass
public void addClass(JavaClassWriter classWriter)
Adds a class to this source file.- Specified by:
addClassin interfaceJavaFileWriter- Parameters:
classWriter- The definition of the class.
-
save
public void save() throws IOExceptionSaves the file by writing out the source contents to whatever file (or alternate representation) was specified (usually by the constructor of the implementation class.- Specified by:
savein interfaceJavaFileWriter- Throws:
IOException- If the file cannot be saved.
-
-