SPT Core API

com.sptci.echo.binding
Class JDOMetaDataGenerator

java.lang.Object
  extended by com.sptci.echo.binding.JDOMetaDataGenerator

public class JDOMetaDataGenerator
extends Object

A JDO meta-data generator. This is a generic generator that does not apply any JDO vendor specific extensions. Sub-classes may be developed that apply vendor specific extensions.

Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: JDOMetaDataGenerator.java 4553 2008-12-24 10:34:16Z rakesh $
Author:
Rakesh Vidyadharan 2006-02-08

Field Summary
protected  Map<String,String> fields
          The fields available in the class for which meta-data is to be generated.
protected  String name
          The name of the class for which the meta-data is to be generated.
protected  String packageName
          The name of the package to which the class belongs.
 
Constructor Summary
protected JDOMetaDataGenerator()
          Default constructor.
  JDOMetaDataGenerator(String name, String packageName, Map<String,String> fields)
          Create a new instance of the class using the specified values.
 
Method Summary
protected  org.jdom.Element fetchEchoPackage(org.jdom.Document document)
          Fetch the element (if it exists) for the package definition for com.sptci.echo.
protected  org.jdom.Element fetchListItem(org.jdom.Document document)
          Fetch the element (if it exists) for the class definition for com.sptci.echo.ListItem.
protected  org.jdom.Element fetchSource(org.jdom.Document document)
          Fetch the element (if it exists) that represents the class representing name.
protected  org.jdom.Element fetchSourcePackage(org.jdom.Document document)
          Fetch the element (if it exists) for the package definition for packageName.
 void generate()
          Generate the JDO meta-data file for a JDO JavaBean.
protected  org.jdom.Element generateEchoPackage()
          Generate the meta-data elements and attributes for the com.sptci.echo package.
protected  void generateFile(File file)
          Generate a new meta-data file with the meta-data for the name JDO object.
protected  org.jdom.Element generateListItem()
          Generate the meta-data for the ListItem class.
protected  org.jdom.Element generateMetaData()
          Generate the meta-data elements and attributes for the JDO object represented by name.
protected  org.jdom.Element generateSource()
          Generate the element for the class represented by name.
protected  org.jdom.Element generateSourcePackage()
          Generate the package (packageName) element for the class represented by name.
protected  void updateFile(File file)
          Add the meta-data for the name JDO object to the existing meta-data file.
protected  void writeFile(File file, org.jdom.Document document)
          Write the specified XML document to the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name
The name of the class for which the meta-data is to be generated.


packageName

protected String packageName
The name of the package to which the class belongs.


fields

protected Map<String,String> fields
The fields available in the class for which meta-data is to be generated.

Constructor Detail

JDOMetaDataGenerator

protected JDOMetaDataGenerator()
Default constructor. No special actions required.


JDOMetaDataGenerator

public JDOMetaDataGenerator(String name,
                            String packageName,
                            Map<String,String> fields)
Create a new instance of the class using the specified values.

Parameters:
name - The name value to set.
packageName - The packageName value to set.
fields - The fields value to set.
Method Detail

generate

public void generate()
              throws org.jdom.JDOMException,
                     IOException
Generate the JDO meta-data file for a 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.
IOException - If errors are encountered while writing to the meta-data file.
See Also:
updateFile(java.io.File), generateFile(java.io.File)

generateFile

protected void generateFile(File file)
                     throws org.jdom.JDOMException,
                            IOException
Generate a new meta-data file with the meta-data for the name JDO object.

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

generateMetaData

protected org.jdom.Element generateMetaData()
Generate the meta-data elements and attributes for the JDO object represented by name.

Returns:
Element The element that represents the JDO object.
See Also:
generateSourcePackage(), generateSource()

generateSourcePackage

protected org.jdom.Element generateSourcePackage()
Generate the package (packageName) element for the class represented by name.

Returns:
Element The element representing the package.

generateSource

protected org.jdom.Element generateSource()
Generate the element for the class represented by name.

Returns:
Element The element representing the class.

generateEchoPackage

protected org.jdom.Element generateEchoPackage()
Generate the meta-data elements and attributes for the com.sptci.echo package.

Returns:
Element The element that represents the meta-data for the package.
See Also:
generateListItem()

writeFile

protected void writeFile(File file,
                         org.jdom.Document document)
                  throws org.jdom.JDOMException,
                         IOException
Write the specified XML document to the specified file.

Parameters:
file - The file to write to.
document - The document to write.
Throws:
org.jdom.JDOMException - If errors are encountered while fetching the element.
IOException - If errors are encountered while writing to the meta-data file.

updateFile

protected void updateFile(File file)
                   throws org.jdom.JDOMException,
                          IOException
Add the meta-data for the name JDO object to the existing meta-data file.

Parameters:
file - The file to update.
Throws:
org.jdom.JDOMException - If errors are encountered while fetching the element.
IOException - If errors are encountered while writing to the meta-data file.
See Also:
fetchSourcePackage(org.jdom.Document), generateMetaData(), fetchSource(org.jdom.Document), generateSource(), fetchEchoPackage(org.jdom.Document), fetchListItem(org.jdom.Document), generateEchoPackage(), generateListItem(), writeFile(java.io.File, org.jdom.Document)

fetchSourcePackage

protected org.jdom.Element fetchSourcePackage(org.jdom.Document document)
                                       throws org.jdom.JDOMException
Fetch the element (if it exists) for the package definition for packageName.

Parameters:
document - The document from which to fetch the element.
Returns:
Element The appropriate element.
Throws:
org.jdom.JDOMException - If errors are encountered while fetching the element.

fetchSource

protected org.jdom.Element fetchSource(org.jdom.Document document)
                                throws org.jdom.JDOMException
Fetch the element (if it exists) that represents the class representing name.

Parameters:
document - The document from which to fetch the element.
Returns:
Element The appropriate element.
Throws:
org.jdom.JDOMException - If errors are encountered while fetching the element.

fetchEchoPackage

protected org.jdom.Element fetchEchoPackage(org.jdom.Document document)
                                     throws org.jdom.JDOMException
Fetch the element (if it exists) for the package definition for com.sptci.echo.

Parameters:
document - The document from which to fetch the element.
Returns:
Element The appropriate element.
Throws:
org.jdom.JDOMException - If errors are encountered while fetching the element.

fetchListItem

protected org.jdom.Element fetchListItem(org.jdom.Document document)
                                  throws org.jdom.JDOMException
Fetch the element (if it exists) for the class definition for com.sptci.echo.ListItem.

Parameters:
document - The document from which to fetch the element.
Returns:
Element The appropriate element.
Throws:
org.jdom.JDOMException - If errors are encountered while fetching the element.

generateListItem

protected org.jdom.Element generateListItem()
Generate the meta-data for the ListItem class.

Returns:
Element The element that represents the meta-data for the class.

SPT Core API