org.enhydra.zeus.generator
Class SimpleGenerator

java.lang.Object
  |
  +--org.enhydra.zeus.generator.SimpleGenerator
All Implemented Interfaces:
Generator

public class SimpleGenerator
extends java.lang.Object
implements Generator

Generator is the portion of Zeus that will convert a set of constraints, visible through a Binding, and output them as generated Java classes (to a File [directory]).

SimpleGenerator is the simplest form of a Generator and takes in either a single Binding or a List of them, and directly generates Java classes.

Version:
1.0
Author:
Brett McLaughlin, Maciej Zawadzki

Field Summary
protected  java.lang.String collectionClass
          The Collection class to use
protected  boolean generateAsSerializable
          This determines if the class should be serializable
protected  java.util.List ignoredBindings
          A list of bindings to ignore
protected  java.io.File implDir
          Directory where all generated implementation classes should be placed.
protected  java.lang.String implPackage
          The package name for the implementation classes.
protected  boolean initialized
          Keeps track of whether the Generator needs to be reinitialized.
protected  java.io.File interfaceDir
          Directory where all generated interfaces should be placed.
protected  java.lang.String interfacePackage
          The package name of the interface/implementation classes
protected  java.lang.String javaPackage
          The package name of the interface/implementation classes
protected  java.io.File outputDir
          Base directory for generated files.
 
Fields inherited from interface org.enhydra.zeus.Generator
DEFAULT_COLLECTION_CLASS
 
Constructor Summary
SimpleGenerator()
           This will construct a new instance of SimpleGenerator.
 
Method Summary
 void generate(Binding binding)
           This will convert from a set of constraints to Java classes.
 boolean generateAsSerializable()
           This will return true if the generator is set to generate Serializable classes, or else false.
 java.lang.String getCollectionClass()
           This will return the current class used for Collection properties.
 java.lang.String getImplementationPackage()
           Returns the Java package to generate implementation classes within.
 java.lang.String getInterfacePackage()
           Returns the Java package to generate interfaces within.
 void setCollectionClass(java.lang.String collectionClass)
           This will set the Collection class to use anytime that a collection of values need to be stored.
 void setGenerateAsSerializable(boolean generateAsSerializable)
           This will allow for setting the generator to generate serializable classes.
 void setIgnoreBinding(java.lang.String bindingName)
           This allows a binding to be ignored.
 void setImplementationPackage(java.lang.String implPackage)
           Sets the Java package to generate new interfaces within.
 void setInterfacePackage(java.lang.String interfacePackage)
           Sets the Java package to generate new interfaces within.
 void setJavaPackage(java.lang.String javaPackage)
           Sets the Java package to generate new interfaces and implementation within.
 void setOutputDirectory(java.io.File outputDir)
           This sets the output directory to output generated classes to.
 void setOutputDirectory(java.lang.String outputDir)
           This sets the output directory to output generated classes to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

collectionClass

protected java.lang.String collectionClass
The Collection class to use

javaPackage

protected java.lang.String javaPackage
The package name of the interface/implementation classes

generateAsSerializable

protected boolean generateAsSerializable
This determines if the class should be serializable

ignoredBindings

protected java.util.List ignoredBindings
A list of bindings to ignore

interfacePackage

protected java.lang.String interfacePackage
The package name of the interface/implementation classes

implPackage

protected java.lang.String implPackage
The package name for the implementation classes.

interfaceDir

protected java.io.File interfaceDir
Directory where all generated interfaces should be placed.

implDir

protected java.io.File implDir
Directory where all generated implementation classes should be placed.

outputDir

protected java.io.File outputDir
Base directory for generated files.

initialized

protected boolean initialized
Keeps track of whether the Generator needs to be reinitialized.
Constructor Detail

SimpleGenerator

public SimpleGenerator()

This will construct a new instance of SimpleGenerator.

Method Detail

setCollectionClass

public void setCollectionClass(java.lang.String collectionClass)

This will set the Collection class to use anytime that a collection of values need to be stored. The default value for this class is stored in Generator.DEFAULT_COLLECTION_CLASS. The class specified should be an implementation of the java.util.Collection interface.

Note that the supplied class name must be fully qualified. For example, java.util.List would be fine, but List would not be.

Specified by:
setCollectionClass in interface Generator
Parameters:
collectionClass - String name of collection to use.

getCollectionClass

public java.lang.String getCollectionClass()

This will return the current class used for Collection properties.

Specified by:
getCollectionClass in interface Generator
Returns:
String - name of class used for Collections.

setJavaPackage

public void setJavaPackage(java.lang.String javaPackage)

Sets the Java package to generate new interfaces and implementation within. For example, supplying the value com.foo.bar to this method and then generating classes, the classes would all be in the com.foo.bar package after generation.

Specified by:
setJavaPackage in interface Generator
Parameters:
javaPackage - String the Java package to generate interfaces and implementation classes within.

getInterfacePackage

public java.lang.String getInterfacePackage()

Returns the Java package to generate interfaces within.

Specified by:
getInterfacePackage in interface Generator
Returns:
String - the Java package to unmarshall interfaces to.

setInterfacePackage

public void setInterfacePackage(java.lang.String interfacePackage)

Sets the Java package to generate new interfaces within. For example, supplying the value com.foo.bar to this method and then generating classes, the interfaces would all be in the com.foo.bar package after generation.

Specified by:
setInterfacePackage in interface Generator
Parameters:
interfacePackage - String the Java package to generate interfaces within.

getImplementationPackage

public java.lang.String getImplementationPackage()

Returns the Java package to generate implementation classes within.

Specified by:
getImplementationPackage in interface Generator
Returns:
String - the Java package to generate implementation classes within.

setImplementationPackage

public void setImplementationPackage(java.lang.String implPackage)

Sets the Java package to generate new interfaces within. For example, supplying the value com.foo.bar to this method and then generating classes, the interfafces would all be in the com.foo.bar package after generation.

Specified by:
setImplementationPackage in interface Generator
Parameters:
implPackage - String the Java package to generate interfaces within.

setOutputDirectory

public void setOutputDirectory(java.lang.String outputDir)

This sets the output directory to output generated classes to.

Specified by:
setOutputDirectory in interface Generator
Parameters:
baseDir - the name of the base directory where all generated classes should be placed

setOutputDirectory

public void setOutputDirectory(java.io.File outputDir)

This sets the output directory to output generated classes to.

Specified by:
setOutputDirectory in interface Generator
Parameters:
outputDir - the File (directory) where all generated classes should be placed

generateAsSerializable

public boolean generateAsSerializable()

This will return true if the generator is set to generate Serializable classes, or else false.

Specified by:
generateAsSerializable in interface Generator
Returns:
boolean - whether classes will be serializable.

setGenerateAsSerializable

public void setGenerateAsSerializable(boolean generateAsSerializable)

This will allow for setting the generator to generate serializable classes. By default, classes are not set to be serializable.

Specified by:
setGenerateAsSerializable in interface Generator
Parameters:
generateAsSerializable - whether or not to generate serializable classes

setIgnoreBinding

public void setIgnoreBinding(java.lang.String bindingName)

This allows a binding to be ignored. This is an intermediary step towards allowing binding schemas. The name of the binding should be passed in here, and no property generation for it will occur.

Specified by:
setIgnoreBinding in interface Generator
Parameters:
bindingName - the name of the binding to ignore.

generate

public void generate(Binding binding)
              throws java.io.IOException

This will convert from a set of constraints to Java classes. It accesses those constraints through the Binding interface, which provides them in a representation-independent format, and then converts them into Java code.

Specified by:
generate in interface Generator
Parameters:
binder - Binder with ability to convert from constraints to Zeus Bindings.
Throws:
IOException - - when errors in writing to the supplied Result occur.


Copyright © 2001 Enhydra. All Rights Reserved.