All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.beans.tools.dataFormatWizard.EmitterUtils

java.lang.Object
   |
   +----com.ibm.beans.tools.dataFormatWizard.EmitterUtils

public class EmitterUtils
extends Object
The EmitterUtils class contains various methods to assist beans which emit java source code.


Variable Index

 o ASTERISK
A String constant whose value is the asterisk.
 o BEGIN_JAVADOC
A String constant whose value is "/**".
 o CLOSE_BRACE
A String constant whose value is "}".
 o DOUBLE_DASH_COMMENT_LINE
A String constant whose value is
" // ============================================="
 o EMITTED_BY
A String constant whose value is
"Emitted by com.ibm.beans.tools.dataFormatWizard.EmitterUtils, for class:".
 o END_JAVADOC
A String constant whose value is an asterisk followed by a slash.
 o INDENT
A String constant used for indenting.
 o OPEN_BRACE
A String constant whose value is "{".
 o QUOTE_MARK
A String constant whose value is the double quote character.
 o SINGLE_DASH_COMMENT_LINE
A String constant whose value is
" // ---------------------------------------------"
 o SLASH
A String constant whose value is a single slash.
 o TWIN_SLASH
A String constant whose value is a double slash.

Constructor Index

 o EmitterUtils()

Method Index

 o capitalize(String, boolean)
Capitalizes or decapitalizes a string.
 o compile(String, Component)
Compiles a new class file from the source code.
 o convertToIdentifier(String)
Converts a string into a valid Java identifier.
 o emitCloseClassDeclaration(PrintWriter, String)
Emits source code for the end of a class declaration.
 o emitCloseMethodDeclaration(PrintWriter, String)
Emits source code for the end of a method declaration.
 o emitDefaultConstructor(PrintWriter, String)
Emits source code for the constructor for a bean.
 o emitFieldAllocation(PrintWriter, String, String, boolean, String)
Emits source code to allocate a declared field of a bean.
 o emitFieldDeclaration(PrintWriter, String, String, String)
Emits source code for the field declaration of a bean property.
 o emitGetterMethod(PrintWriter, String, String)
Emits source code for the getter method for a bean property.
 o emitMultiLineComment(PrintWriter, String[])
Emits source code for a multi-line comment.
 o emitOpenClassDeclaration(PrintWriter, String, String, String[])
Emits source code for the beginning of a class declaration.
 o emitOpenMethodDeclaration(PrintWriter, String, String, String[], String[], String[])
Emits source code for the beginning of a method declaration.
 o emitPackageStatement(PrintWriter, String)
Emits source code for the package statement for a bean.
 o emitSetterMethod(PrintWriter, String, String)
Emits source code for the setter method for a bean property.
 o emitSingleLineComment(PrintWriter, String)
Emits source code for a single-line comment.
 o emitStatement(PrintWriter, String)
Emits source code for a general statement within a bean method.
 o getSourceCodeStream(String)
Opens a source code output stream.
 o getSourceFileName(String, String)
Determines the name of the source code output file for a new class.

Variables

 o INDENT
 public static final String INDENT
A String constant used for indenting. The value is four spaces.

 o OPEN_BRACE
 public static final String OPEN_BRACE
A String constant whose value is "{".

 o CLOSE_BRACE
 public static final String CLOSE_BRACE
A String constant whose value is "}".

 o QUOTE_MARK
 public static final String QUOTE_MARK
A String constant whose value is the double quote character.

 o ASTERISK
 public static final String ASTERISK
A String constant whose value is the asterisk.

 o SLASH
 public static final String SLASH
A String constant whose value is a single slash.

 o TWIN_SLASH
 public static final String TWIN_SLASH
A String constant whose value is a double slash.

 o BEGIN_JAVADOC
 public static final String BEGIN_JAVADOC
A String constant whose value is "/**".

 o END_JAVADOC
 public static final String END_JAVADOC
A String constant whose value is an asterisk followed by a slash.

 o SINGLE_DASH_COMMENT_LINE
 public static final String SINGLE_DASH_COMMENT_LINE
A String constant whose value is
" // ---------------------------------------------"

 o DOUBLE_DASH_COMMENT_LINE
 public static final String DOUBLE_DASH_COMMENT_LINE
A String constant whose value is
" // ============================================="

 o EMITTED_BY
 public static final String EMITTED_BY
A String constant whose value is
"Emitted by com.ibm.beans.tools.dataFormatWizard.EmitterUtils, for class:".

Constructors

 o EmitterUtils
 public EmitterUtils()

Methods

 o compile
 public static boolean compile(String sourceFileName,
                               Component forApplication)
Compiles a new class file from the source code.

Parameters:
sourceFileName -
The fully-qualified file name for the source code of the new class.
forApplication -
A display component for the application invoking the compiler. A compiler status dialog window is shown above this frame.
Returns:
true if the compilation was successful.
 o capitalize
 public static String capitalize(String aString,
                                 boolean capitalize)
Capitalizes or decapitalizes a string.

Parameters:
aString - A string to be capitalized or decapitalized.
capitalize - true if the string should be capitalized; false otherwise.
Returns:
The capitalized or decapitalized string.
 o convertToIdentifier
 public static String convertToIdentifier(String aString)
Converts a string into a valid Java identifier. The following transformations are applied to the string:

Parameters:
aString -
A string to be converted into a Java identifier.
Returns:
The identifier string.
 o emitPackageStatement
 public static void emitPackageStatement(PrintWriter sourceCodeStream,
                                         String packageName)
Emits source code for the package statement for a bean.

Parameters:
sourceCodeStream -
An output stream for the source code.
packageName -
The package name for the bean.
 o emitOpenClassDeclaration
 public static void emitOpenClassDeclaration(PrintWriter sourceCodeStream,
                                             String classname,
                                             String superclass,
                                             String interfaces[])
Emits source code for the beginning of a class declaration.

Parameters:
sourceCodeStream -
An output stream for the source code.
classname -
The name of the new class.
superclass -
The name of the parent class extended by the new class.
interfaces -
A list of names of interfaces implemented by the new class.
 o emitCloseClassDeclaration
 public static void emitCloseClassDeclaration(PrintWriter sourceCodeStream,
                                              String classname)
Emits source code for the end of a class declaration.

Parameters:
sourceCodeStream -
An output stream for the source code.
classname -
The name of the new class.
 o emitDefaultConstructor
 public static void emitDefaultConstructor(PrintWriter sourceCodeStream,
                                           String classname)
Emits source code for the constructor for a bean.

Parameters:
sourceCodeStream -
An output stream for the source code.
classname -
The class name of the bean.
 o emitSingleLineComment
 public static void emitSingleLineComment(PrintWriter sourceCodeStream,
                                          String comment)
Emits source code for a single-line comment.

Parameters:
sourceCodeStream -
An output stream for the source code.
comment -
The comment line to be emitted.
 o emitMultiLineComment
 public static void emitMultiLineComment(PrintWriter sourceCodeStream,
                                         String commentLines[])
Emits source code for a multi-line comment.

Parameters:
sourceCodeStream -
An output stream for the source code.
commentLines -
A set of comment lines to be emitted.
 o emitFieldDeclaration
 public static void emitFieldDeclaration(PrintWriter sourceCodeStream,
                                         String propertyTypeName,
                                         String propertyName,
                                         String defaultValue)
Emits source code for the field declaration of a bean property.

Parameters:
sourceCodeStream -
An output stream for the source code.
propertyTypeName -
The class name or primitive type name of the property.
propertyName -
The name of the property.
defaultValue -
The default property value.
 o emitFieldAllocation
 public static void emitFieldAllocation(PrintWriter sourceCodeStream,
                                        String propertyName,
                                        String propertyTypeName,
                                        boolean isPrimitive,
                                        String constructorArgs)
Emits source code to allocate a declared field of a bean.

Parameters:
sourceCodeStream -
An output stream for the source code.
propertyName -
The name of the property.
propertyTypeName -
The class name or primitive type name of the property.
isPrimitive -
true if the property type is a Java primitive type. Any constructor arguments are ignored. false if the property type is not a Java primitive type.
constructorArgs -
The constructor arguments (if any) for the new property instance.
 o emitGetterMethod
 public static void emitGetterMethod(PrintWriter sourceCodeStream,
                                     String propertyTypeName,
                                     String propertyName)
Emits source code for the getter method for a bean property.

Parameters:
sourceCodeStream -
An output stream for the source code.
propertyTypeName -
The class name or primitive type name of the property.
propertyName -
The name of the property.
 o emitSetterMethod
 public static void emitSetterMethod(PrintWriter sourceCodeStream,
                                     String propertyTypeName,
                                     String propertyName)
Emits source code for the setter method for a bean property.

Parameters:
sourceCodeStream -
An output stream for the source code.
propertyTypeName -
The class name or primitive type name of the property.
propertyName -
The name of the property.
 o emitOpenMethodDeclaration
 public static void emitOpenMethodDeclaration(PrintWriter sourceCodeStream,
                                              String returnTypeName,
                                              String methodName,
                                              String argTypeNames[],
                                              String argNames[],
                                              String exceptions[])
Emits source code for the beginning of a method declaration.

Parameters:
sourceCodeStream -
An output stream for the source code.
returnTypeName -
The return type name of the new method.
methodName -
The name of the new method.
argTypeNames -
A list of type names for the arguments of the new method.
argNames -
A list of names for the arguments of the new method.
exceptions -
A list of exceptions thrown by the new method.
 o emitCloseMethodDeclaration
 public static void emitCloseMethodDeclaration(PrintWriter sourceCodeStream,
                                               String methodName)
Emits source code for the end of a method declaration.

Parameters:
sourceCodeStream -
An output stream for the source code.
methodName -
The new method name.
 o emitStatement
 public static void emitStatement(PrintWriter sourceCodeStream,
                                  String statement)
Emits source code for a general statement within a bean method.

Parameters:
sourceCodeStream -
An output stream for the source code.
statement -
The statement to be emitted.
 o getSourceFileName
 public static String getSourceFileName(String packageName,
                                        String classname)
Determines the name of the source code output file for a new class.

Parameters:
packageName - The package name for the class.
classname - The name of the class.
Returns:
The filename of the source code output file.
 o getSourceCodeStream
 public static PrintWriter getSourceCodeStream(String filename)
Opens a source code output stream.

Parameters:
filename - The name of the source code output file.
Returns:
An output stream connected to the source code file.

All Packages  Class Hierarchy  This Package  Previous  Next  Index