org.sourceflow.java
Class JavaFile

java.lang.Object
  extended byorg.sourceflow.CodeElement
      extended byorg.sourceflow.CodeContainer
          extended byorg.sourceflow.CodeFile
              extended byorg.sourceflow.java.JavaFile
All Implemented Interfaces:
java.lang.Comparable

public class JavaFile
extends CodeFile

A class generating a Java code file.


Constructor Summary
JavaFile(java.io.File basedir)
          Creates a new Java code file in the specified file.
JavaFile(java.io.File basedir, JavaPackage filePackage)
          Creates a new Java code file in the specified base directory and package.
 
Method Summary
 void addClass(JavaClass cls)
          Adds a class to the file.
 void addComment(JavaComment comment)
          Adds a comment to this file.
 void addImport(JavaImport imp)
          Adds an import to the file.
 void addInterface(JavaInterface ifc)
          Adds an interface to the file.
 int category()
          Returns a numeric category number for the code element.
 java.lang.String getName()
          Returns the file name.
 void print(java.io.PrintWriter out, CodeStyle style, int indent)
          Prints the file contents to the specified output stream.
 
Methods inherited from class org.sourceflow.CodeFile
getFile, toString, write
 
Methods inherited from class org.sourceflow.CodeContainer
addElement, printContents, size
 
Methods inherited from class org.sourceflow.CodeElement
compareTo, printSeparator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaFile

public JavaFile(java.io.File basedir)
Creates a new Java code file in the specified file.

Parameters:
basedir - the base output directory

JavaFile

public JavaFile(java.io.File basedir,
                JavaPackage filePackage)
Creates a new Java code file in the specified base directory and package. The file name will be retrieved from the first class or interface added to this file.

Parameters:
basedir - the base output directory
filePackage - the package the file belongs to
Method Detail

getName

public java.lang.String getName()
Returns the file name. Note that if no class has been added to the file, a default file name will be returned.

Specified by:
getName in class CodeFile
Returns:
the file name

addComment

public void addComment(JavaComment comment)
Adds a comment to this file.

Parameters:
comment - the new file comment

addImport

public void addImport(JavaImport imp)
Adds an import to the file.

Parameters:
imp - the import to add

addClass

public void addClass(JavaClass cls)
Adds a class to the file.

Parameters:
cls - the class to add

addInterface

public void addInterface(JavaInterface ifc)
Adds an interface to the file.

Parameters:
ifc - the interface to add

category

public int category()
Returns a numeric category number for the code element. A lower category number implies that the code element should be placed before code elements with a higher category number within a declaration.

Specified by:
category in class CodeElement
Returns:
the category number

print

public void print(java.io.PrintWriter out,
                  CodeStyle style,
                  int indent)
Prints the file contents to the specified output stream.

Specified by:
print in class CodeElement
Parameters:
out - the output stream
style - the code style to use
indent - the indentation level