public class JDOModelGenerator extends ModelGenerator
ModelGenerator, generates an additional
Factory class to implement interactions with the JDO
datastore, and a default JDO metadata file.
The following shows the invocation semantics for this class:
java -classpath <path to classes>:sptecho.jar:<path to Echo2_App.jar>:<path to jdom>:<path to jaxen> \
com.sptci.echo.JDOModelGenerator \
<fully qualified name of UI class>
Copyright 2006 Sans Pareil Technologies, Inc.
JDOMetaDataGeneratorimports, source, uiFieldsfields, name, primitives| Constructor and Description |
|---|
JDOModelGenerator(String name)
Delegates to the super-class constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected StringBuilder |
changeDefinition(StringBuilder builder)
Replace the class definition with a new definition as a sub-class
of JDOObject.
|
void |
generate()
Over-ridden to generate the factory class source and metadata file
in addition to the JavaBean source.
|
protected String |
generateCloneMethod()
Over-ridden to return an empty string.
|
protected String |
generateCompareToMethod()
Over-ridden to return an empty string.
|
protected String |
generateCreateXStreamMethod()
Return the custom implementation of the
createXStream
method. |
protected String |
generateDeleteMethod()
Generate the
delete method that will be used to delete
a JDO JavaBean to the JDO data store. |
protected void |
generateFactory()
Generate a
Factory class that handles interactions
between the JDO JavaBean objects and the JDO datastore. |
protected String |
generateFactoryInitialisers()
Generate the initialiser methods for the factory class.
|
protected String |
generateFactoryMethods()
Generate additional factory methods for fetching the JDO
JavaBean instances from the JDO data store.
|
protected void |
generateMetaData()
Generate the JDO meta-data file for the JDO JavaBean.
|
protected String |
generateMethods()
Generate the methods for the JavaBean.
|
protected String |
generatePropertyChangeFields()
Over-ridden to return an empty string.
|
protected String |
generatePropertyChangeMethods()
Over-ridden to return an empty string.
|
protected String |
generateSaveMethod()
Generate the
save method that will be used to save
a JDO JavaBean to the JDO data store. |
protected String |
generateToStringMethod()
Over-ridden to return the
createXStream method. |
static void |
main(String[] args)
Main method.
|
protected StringBuilder |
removeHash(StringBuilder builder)
Remove the fields for the hash code.
|
protected StringBuilder |
removeObsoleteCode(StringBuilder builder)
Remove code that is implemented in the parent JDOObject class.
|
protected StringBuilder |
removeOldValue(StringBuilder builder)
Remove assignment of old value to a temporary value used to fire
property change events from mutator methods.
|
protected StringBuilder |
removePropertyChange(StringBuilder builder)
Remove the
firePropertyChange method invocation in
the mutator methods. |
generateBeanMethods, generateConstructors, generateDefaultConstructor, generateDesignatedConstructor, generateFields, generateSource, processComponentgenerateEqualsMethod, generateHashCodeMethodpublic JDOModelGenerator(String name) throws ClassNotFoundException
name - The fully qualified name of the class. Example:
com.sptci.demo.InputForm.ClassNotFoundException - If the class corresponding to the
name cannot be found in the classpath.public void generate()
throws Exception
generate in class ModelGeneratorException - If errors are encountered while generating
the source file.generateFactory(),
generateMetaData()protected String generatePropertyChangeFields()
generatePropertyChangeFields in class ModelGeneratorprotected String generatePropertyChangeMethods()
generatePropertyChangeMethods in class ModelGeneratorprotected String generateToStringMethod()
createXStream method. The
base JDOObject contains a default implementation of the toString
method which is the same as the toXML method.generateToStringMethod in class CodeGeneratorgenerateCreateXStreamMethod()protected String generateCreateXStreamMethod()
createXStream
method.protected String generateCompareToMethod()
compareTo
is implemented in the base JDOObject class.generateCompareToMethod in class CodeGeneratorprotected String generateCloneMethod()
clone
is implemented in the base JDOObject class.generateCloneMethod in class CodeGeneratorprotected StringBuilder removeObsoleteCode(StringBuilder builder)
builder - The StringBuilder to be cleaned.changeDefinition(java.lang.StringBuilder),
removeHash(java.lang.StringBuilder),
removePropertyChange(java.lang.StringBuilder)protected StringBuilder changeDefinition(StringBuilder builder)
builder - The StringBuilder to be cleaned.protected StringBuilder removeHash(StringBuilder builder)
builder - The StringBuilder to be cleaned.protected StringBuilder removeOldValue(StringBuilder builder)
builder - The StringBuilder to be cleaned.protected StringBuilder removePropertyChange(StringBuilder builder)
firePropertyChange method invocation in
the mutator methods.builder - The StringBuilder to be cleaned.protected String generateMethods()
generateMethods in class ModelGeneratorModelGenerator.generateMethods()protected void generateFactory()
throws IOException
Factory class that handles interactions
between the JDO JavaBean objects and the JDO datastore.IOException - If errors are encountered while writing the
generated source file.generateFactoryInitialisers(),
generateSaveMethod(),
generateFactoryMethods()protected String generateFactoryInitialisers()
protected String generateSaveMethod()
save method that will be used to save
a JDO JavaBean to the JDO data store.protected String generateDeleteMethod()
delete method that will be used to delete
a JDO JavaBean to the JDO data store.protected String generateFactoryMethods()
protected void generateMetaData()
throws org.jdom.JDOMException,
IOException
Uses JDOM and Jaxen for parsing an existing meta-data file and for creating or updating the file.
org.jdom.JDOMException - If errors are encountered while fetching
the element.IOException - If errors are encountered while writing to
the meta-data file.JDOMetaDataGenerator.generate()public static void main(String[] args)
args - The command line arguments use.