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.
-
ASTERISK
- A String constant whose value is the asterisk.
-
BEGIN_JAVADOC
- A String constant whose value is "/**".
-
CLOSE_BRACE
- A String constant whose value is "}".
-
DOUBLE_DASH_COMMENT_LINE
- A String constant whose value is
" // ============================================="
-
EMITTED_BY
- A String constant whose value is
"Emitted by com.ibm.beans.tools.dataFormatWizard.EmitterUtils, for class:".
-
END_JAVADOC
- A String constant whose value is an asterisk followed by a slash.
-
INDENT
- A String constant used for indenting.
-
OPEN_BRACE
- A String constant whose value is "{".
-
QUOTE_MARK
- A String constant whose value is the double quote character.
-
SINGLE_DASH_COMMENT_LINE
- A String constant whose value is
" // ---------------------------------------------"
-
SLASH
- A String constant whose value is a single slash.
-
TWIN_SLASH
- A String constant whose value is a double slash.
-
EmitterUtils()
-
-
capitalize(String, boolean)
- Capitalizes or decapitalizes a string.
-
compile(String, Component)
- Compiles a new class file from the source code.
-
convertToIdentifier(String)
- Converts a string into a valid Java identifier.
-
emitCloseClassDeclaration(PrintWriter, String)
- Emits source code for the end of a class declaration.
-
emitCloseMethodDeclaration(PrintWriter, String)
- Emits source code for the end of a method declaration.
-
emitDefaultConstructor(PrintWriter, String)
- Emits source code for the constructor for a bean.
-
emitFieldAllocation(PrintWriter, String, String, boolean, String)
- Emits source code to allocate a declared field of a bean.
-
emitFieldDeclaration(PrintWriter, String, String, String)
- Emits source code for the field declaration of a bean property.
-
emitGetterMethod(PrintWriter, String, String)
- Emits source code for the getter method for a bean property.
-
emitMultiLineComment(PrintWriter, String[])
- Emits source code for a multi-line comment.
-
emitOpenClassDeclaration(PrintWriter, String, String, String[])
- Emits source code for the beginning of a class declaration.
-
emitOpenMethodDeclaration(PrintWriter, String, String, String[], String[], String[])
- Emits source code for the beginning of a method declaration.
-
emitPackageStatement(PrintWriter, String)
- Emits source code for the package statement for a bean.
-
emitSetterMethod(PrintWriter, String, String)
- Emits source code for the setter method for a bean property.
-
emitSingleLineComment(PrintWriter, String)
- Emits source code for a single-line comment.
-
emitStatement(PrintWriter, String)
- Emits source code for a general statement within a bean method.
-
getSourceCodeStream(String)
- Opens a source code output stream.
-
getSourceFileName(String, String)
- Determines the name of the source code output file for a new class.
INDENT
public static final String INDENT
- A String constant used for indenting. The value is four spaces.
OPEN_BRACE
public static final String OPEN_BRACE
- A String constant whose value is "{".
CLOSE_BRACE
public static final String CLOSE_BRACE
- A String constant whose value is "}".
QUOTE_MARK
public static final String QUOTE_MARK
- A String constant whose value is the double quote character.
ASTERISK
public static final String ASTERISK
- A String constant whose value is the asterisk.
SLASH
public static final String SLASH
- A String constant whose value is a single slash.
TWIN_SLASH
public static final String TWIN_SLASH
- A String constant whose value is a double slash.
BEGIN_JAVADOC
public static final String BEGIN_JAVADOC
- A String constant whose value is "/**".
END_JAVADOC
public static final String END_JAVADOC
- A String constant whose value is an asterisk followed by a slash.
SINGLE_DASH_COMMENT_LINE
public static final String SINGLE_DASH_COMMENT_LINE
- A String constant whose value is
" // ---------------------------------------------"
DOUBLE_DASH_COMMENT_LINE
public static final String DOUBLE_DASH_COMMENT_LINE
- A String constant whose value is
" // ============================================="
EMITTED_BY
public static final String EMITTED_BY
- A String constant whose value is
"Emitted by com.ibm.beans.tools.dataFormatWizard.EmitterUtils, for class:".
EmitterUtils
public EmitterUtils()
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.
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.
convertToIdentifier
public static String convertToIdentifier(String aString)
- Converts a string into a valid Java identifier.
The following transformations are applied to the string:
- Any characters that are not blanks and are not acceptable
for use in Java identifiers are converted to 'x' characters.
- Any blank characters are deleted, and the next valid
identifier character following the blanks are converted
to uppercase.
- Parameters:
- aString -
- A string to be converted into a
Java identifier.
- Returns:
- The identifier string.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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