org.exolab.castor.builder
Class SingleClassGenerator
java.lang.Object
org.exolab.castor.builder.SingleClassGenerator
public final class SingleClassGenerator
extends java.lang.Object
Writes a single class (and any associated inner classes) to a file.
$Revision: 0000 $ $Date: $
SourceGenerator | getSourceGenerator() - Returns the
SourceGenerator instance that created this class.
|
(package private) boolean | process(JClass jClass, SGStateInfo state) - Processes the given JClass by checking for class name conflicts, and if
there are none, making the class as processed and then printing the class
and, if appropriate, its class descriptors.
|
(package private) boolean | process(JClass[] classes, SGStateInfo state) - Processes the given JClasses, one by one, stopping if the SourceGenerator
state indicates STOP after processing one class.
|
(package private) boolean | processIfNotAlreadyProcessed(Enumeration classKeys, SGStateInfo state) - Processes the JClass mapped by the provided key unless the JClass has
already been processed.
|
void | setDescriptorCreation(boolean createDescriptors) - Sets whether or not to create ClassDescriptors for the generated classes.
|
void | setDestDir(String destDir) - Sets the destination directory.
|
void | setJClassPrinter(String classPrinterType) - Sets the JClassPrinter instance from the given string key.
|
void | setLineSeparator(String lineSeparator) - Sets the line separator to use when printing the source code.
|
void | setNameConflictStrategy(String nameConflictStrategy) - Sets the desired
ClassNameCRStrategy instance type to be used
for name conflict resolution.
|
void | setPromptForOverwrite(boolean promptForOverwrite) - Sets whether or not to prompt when we would otherwise overwrite an
existing JClass.
|
SingleClassGenerator
public SingleClassGenerator(ConsoleDialog dialog,
SourceGenerator sourceGenerator,
String conflictStrategyType,
String jClassPrinterType)
Creates an instance of this class.
dialog
- A ConsoleDialog instancesourceGenerator
- A SourceGenerator instanceconflictStrategyType
- Type of the ClassNameCRStrategy
instance to be used.jClassPrinterType
- The string representation of the printer to be used,
process
(package private) boolean process(JClass jClass,
SGStateInfo state)
throws IOException
Processes the given JClass by checking for class name conflicts, and if
there are none, making the class as processed and then printing the class
and, if appropriate, its class descriptors.
If there is a class name conflict, at best the user stops the source
generation and at worst the user continues, skipping this class.
jClass
- the class to processstate
- SourceGenerator state
- true if processing is allowed to continue, false if the
SourceGenerator state is STOP_STATUS,
process
(package private) boolean process(JClass[] classes,
SGStateInfo state)
throws IOException
Processes the given JClasses, one by one, stopping if the SourceGenerator
state indicates STOP after processing one class.
classes
- Array of classes to processstate
- SourceGenerator state
- true if processing is allowed to continue, false if the
SourceGenerator state is STOP_STATUS,
processIfNotAlreadyProcessed
(package private) boolean processIfNotAlreadyProcessed(Enumeration classKeys,
SGStateInfo state)
throws IOException
Processes the JClass mapped by the provided key unless the JClass has
already been processed.
classKeys
- Enumeration over a collection of keys to ClassInfosstate
- SourceGenerator state
- true if processing is allowed to continue, false if the
SourceGenerator state is STOP_STATUS,
setDescriptorCreation
public void setDescriptorCreation(boolean createDescriptors)
Sets whether or not to create ClassDescriptors for the generated classes.
By default, descriptors are generated.
createDescriptors
- a boolean, when true indicates to generated ClassDescriptors
setDestDir
public void setDestDir(String destDir)
Sets the destination directory.
destDir
- the destination directory.
setJClassPrinter
public void setJClassPrinter(String classPrinterType)
Sets the JClassPrinter instance from the given string key.
classPrinterType
- The string identifier if the printer,
setLineSeparator
public void setLineSeparator(String lineSeparator)
Sets the line separator to use when printing the source code.
lineSeparator
- the line separator to use when printing the source code. This
method is useful if you are generating source on one platform,
but will be compiling the source on a different platform.
Note:This can be any string, so be careful. I
recommend either using the default or using one of the
following:
windows systems use: "\r\n"
unix systems use: "\n"
mac systems use: "\r"
setNameConflictStrategy
public void setNameConflictStrategy(String nameConflictStrategy)
setPromptForOverwrite
public void setPromptForOverwrite(boolean promptForOverwrite)
Sets whether or not to prompt when we would otherwise overwrite an
existing JClass. If set to false, then it is always OK to overwrite
an existing class. If set to true, the user will be prompted.
promptForOverwrite
- the new value
Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com