com.sptci.echo2
Class JDOModelGenerator

java.lang.Object
  extended by com.sptci.CodeGenerator
      extended by com.sptci.echo2.ModelGenerator
          extended by com.sptci.echo2.JDOModelGenerator

public class JDOModelGenerator
extends ModelGenerator

A JDO JavaBean generator. In addition to generating the source file as implemented in 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.echo2.JDOModelGenerator \
    <fully qualified name of UI class>
 

Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: JDOModelGenerator.java,v 1.3 2006/02/15 17:23:32 rakesh Exp $
Author:
Rakesh Vidyadharan 2006-02-08
See Also:
JDOMetaDataGenerator

Field Summary
 
Fields inherited from class com.sptci.echo2.ModelGenerator
imports, source, uiFields
 
Fields inherited from class com.sptci.CodeGenerator
fields, name, primitives
 
Constructor Summary
JDOModelGenerator(java.lang.String name)
          Delegates to the super-class constructor.
 
Method Summary
protected  void addInstanceCallbacks()
          Add InstanceCallbacks support to the JDO JavaBean.
 void generate()
          Over-ridden to generate the factory class source and metadata file in addition to the JavaBean source.
protected  java.lang.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  java.lang.String generateFactoryInitialisers()
          Generate the initialiser methods for the factory class.
protected  java.lang.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  java.lang.String generateMethods()
          Generate the methods for the JavaBean.
protected  java.lang.String generateSaveMethod()
          Generate the save method that will be used to save a JDO JavaBean to the JDO data store.
static void main(java.lang.String[] args)
          Main method.
 
Methods inherited from class com.sptci.echo2.ModelGenerator
generateBeanMethods, generateConstructors, generateDefaultConstructor, generateDesignatedConstructor, generateFields, generatePropertyChangeFields, generatePropertyChangeMethods, generateSource, processComponent
 
Methods inherited from class com.sptci.CodeGenerator
generateCloneMethod, generateCompareToMethod, generateEqualsMethod, generateHashCodeMethod, generateToStringMethod
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDOModelGenerator

public JDOModelGenerator(java.lang.String name)
                  throws java.lang.ClassNotFoundException
Delegates to the super-class constructor.

Parameters:
name - The fully qualified name of the class. Example: com.sptci.demo.InputForm.
Throws:
java.lang.ClassNotFoundException - If the class corresponding to the name cannot be found in the classpath.
Method Detail

generate

public void generate()
              throws java.lang.Exception
Over-ridden to generate the factory class source and metadata file in addition to the JavaBean source.

Overrides:
generate in class ModelGenerator
Throws:
java.lang.Exception - If errors are encountered while generating the source file.
See Also:
addInstanceCallbacks(), generateFactory(), generateMetaData()

addInstanceCallbacks

protected void addInstanceCallbacks()
                             throws java.lang.Exception
Add InstanceCallbacks support to the JDO JavaBean. Write the modified source code back to the source file.

Throws:
java.lang.Exception - If errors are encountered while writing to the file.
See Also:
ModelGenerator.generate()

generateMethods

protected java.lang.String generateMethods()
Generate the methods for the JavaBean.

Overrides:
generateMethods in class ModelGenerator
Returns:
String The source code for the methods to be included in the JavaBean.
See Also:
ModelGenerator.generateMethods()

generateFactory

protected void generateFactory()
                        throws java.io.IOException
Generate a Factory class that handles interactions between the JDO JavaBean objects and the JDO datastore.

Throws:
java.io.IOException - If errors are encountered while writing the generated source file.
See Also:
generateFactoryInitialisers(), generateSaveMethod(), generateFactoryMethods()

generateFactoryInitialisers

protected java.lang.String generateFactoryInitialisers()
Generate the initialiser methods for the factory class.

Returns:
String The source code for the initialisers.

generateSaveMethod

protected java.lang.String generateSaveMethod()
Generate the save method that will be used to save a JDO JavaBean to the JDO data store.

Returns:
String The source code for the save method.

generateDeleteMethod

protected java.lang.String generateDeleteMethod()
Generate the delete method that will be used to delete a JDO JavaBean to the JDO data store.

Returns:
String The source code for the save method.

generateFactoryMethods

protected java.lang.String generateFactoryMethods()
Generate additional factory methods for fetching the JDO JavaBean instances from the JDO data store.

Returns:
String The source code for the factory methods.

generateMetaData

protected void generateMetaData()
                         throws org.jdom.JDOMException,
                                java.io.IOException
Generate the JDO meta-data file for the JDO JavaBean.

Uses JDOM and Jaxen for parsing an existing meta-data file and for creating or updating the file.

Throws:
org.jdom.JDOMException - If errors are encountered while fetching the element.
java.io.IOException - If errors are encountered while writing to the meta-data file.
See Also:
JDOMetaDataGenerator.generate()

main

public static void main(java.lang.String[] args)
Main method.



Copyright © 2006 Sans Pareil Technologies, Inc. All Rights Reserved.