com.sun.jdo.spi.persistence.utility.generator.io
Class IOJavaFileWriter

java.lang.Object
  extended by com.sun.jdo.spi.persistence.utility.generator.io.IOJavaFileWriter
All Implemented Interfaces:
JavaFileWriter

public class IOJavaFileWriter
extends java.lang.Object
implements JavaFileWriter

This implementation of the JavaFileWriter interface is based on File and simple StringBuffer "println" type statements.

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

Author:
raccah

Constructor Summary
IOJavaFileWriter(java.io.File file)
          Creates a new instance of IOJavaFileWriter.
 
Method Summary
 void addClass(JavaClassWriter classWriter)
          Adds a class to this source file.
 void addImport(java.lang.String importName, java.lang.String[] comments)
          Adds an import statement for this source file.
protected static java.util.ResourceBundle getMessages()
           
 void save()
          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.
 void setPackage(java.lang.String packageName, java.lang.String[] comments)
          Sets the package for this file.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IOJavaFileWriter

public IOJavaFileWriter(java.io.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 java.util.ResourceBundle getMessages()
Returns:
I18N message handler for this element

setPackage

public void setPackage(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 $).

Specified by:
setPackage in interface JavaFileWriter
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(java.lang.String importName,
                      java.lang.String[] comments)
Adds an import statement for this source file.

Specified by:
addImport in interface JavaFileWriter
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:
addClass in interface JavaFileWriter
Parameters:
classWriter - The definition of the class.

save

public void save()
          throws java.io.IOException
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.

Specified by:
save in interface JavaFileWriter
Throws:
java.io.IOException - If the file cannot be saved.

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the generated file.


Copyright © 2012 GlassFish Community. All Rights Reserved.