org.enhydra.zeus.util
Class BaseSourceGenerator

java.lang.Object
  |
  +--org.enhydra.zeus.util.BaseSourceGenerator
Direct Known Subclasses:
DTDSourceGenerator, XSDSourceGenerator

public abstract class BaseSourceGenerator
extends java.lang.Object

This provides basic functionality for classes that need to implement the SourceGenerator interface.

Author:
Brett McLaughlin

Field Summary
protected  boolean collapseSimpleElements
          Determines whether simple elements map to data members on parent clases or to their own classes.
protected  java.io.Reader constraintsReader
          The reader for reading constraints from
protected  boolean generateAsSerializable
          Whether or not to generate classes as serializable
protected  java.lang.String interfacePackage
          The package name of the interface/implementation classes
protected  java.lang.String javaPackage
          The package to generate classes within
protected  java.lang.String namePrefix
          Prefix to be prepended to the name of every generated interface and class.
protected  java.io.File outputDir
          The directory to output classes to
 
Constructor Summary
BaseSourceGenerator()
           This sets up defaults for the generator.
 
Method Summary
 void generate()
           This method performs class generation.
protected abstract  java.util.List getConstraintBindings()
           This defines a contract for subclasses to allow them to get the Zeus Binding objects to generate code from.
 void setCollapseSimpleElements(boolean collapseSimpleElements)
           This method allows the developer to specify that all simple XML elements (elements with #PCDATA content) should map to data members on parent member classes rather than their own classes.
 void setConstraintsInput(java.io.File file)
           This allows for supplying the constraints file to use for source code generation as a File.
 void setConstraintsInput(java.io.InputStream inputStream)
           This allows for supplying the constraints file to use for source code generation as an InputStream.
 void setConstraintsInput(java.io.Reader reader)
           This allows for supplying the constraints file to use for source code generation as a FileReader.
 void setConstraintsInput(java.lang.String fileURI)
           This allows for supplying the constraints file to use for source code generation as a String URI.
 void setGenerateAsSerializable(boolean generateAsSerializable)
           This will set whether or not to set source code classes as serializable (implementing java.io.Serializable.
 void setInterfacePackage(java.lang.String interfacePackage)
           Sets the Java package to generate new interfaces within.
 void setJavaPackage(java.lang.String javaPackage)
           This will set the package for generating classes within.
 void setNamePrefix(java.lang.String namePrefix)
           This method allows the developer to set a prefix that will be prepended to the name of every generated interface and class.
 void setOutputDir(java.io.File outputDir)
           This allows specification of an output directory for the generated classes.
 void setOutputDir(java.lang.String outputDir)
           This allows specification of an output directory for the generated classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constraintsReader

protected java.io.Reader constraintsReader
The reader for reading constraints from

outputDir

protected java.io.File outputDir
The directory to output classes to

javaPackage

protected java.lang.String javaPackage
The package to generate classes within

generateAsSerializable

protected boolean generateAsSerializable
Whether or not to generate classes as serializable

namePrefix

protected java.lang.String namePrefix
Prefix to be prepended to the name of every generated interface and class.

collapseSimpleElements

protected boolean collapseSimpleElements
Determines whether simple elements map to data members on parent clases or to their own classes.

interfacePackage

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

BaseSourceGenerator

public BaseSourceGenerator()

This sets up defaults for the generator.

Method Detail

setConstraintsInput

public void setConstraintsInput(java.lang.String fileURI)
                         throws java.io.IOException

This allows for supplying the constraints file to use for source code generation as a String URI.

Parameters:
fileURI - String URI for constraints file.
Throws:
IOException - - when the specified file URI is invalid.

setConstraintsInput

public void setConstraintsInput(java.io.File file)
                         throws java.io.IOException

This allows for supplying the constraints file to use for source code generation as a File.

Parameters:
file - File to read constraints from.
Throws:
IOException - - when the specified file URI is invalid.

setConstraintsInput

public void setConstraintsInput(java.io.Reader reader)

This allows for supplying the constraints file to use for source code generation as a FileReader.

Parameters:
reader - Reader to read constraints from.

setConstraintsInput

public void setConstraintsInput(java.io.InputStream inputStream)

This allows for supplying the constraints file to use for source code generation as an InputStream.

Parameters:
inputStream - InputStream to read constraints from.

setOutputDir

public void setOutputDir(java.lang.String outputDir)
                  throws java.io.IOException

This allows specification of an output directory for the generated classes.

Parameters:
outputDirString - String specifying output directory for generated classes.
Throws:
IOException - - when invalid direcotory is specified

setOutputDir

public void setOutputDir(java.io.File outputDir)
                  throws java.io.IOException

This allows specification of an output directory for the generated classes.

Parameters:
outputDir - File specifying output directory for generated classes.
Throws:
IOException - - when invalid direcotory is specified

setJavaPackage

public void setJavaPackage(java.lang.String javaPackage)

This will set the package for generating classes within.

Parameters:
javaPackage - the package to generate classes within.

setGenerateAsSerializable

public void setGenerateAsSerializable(boolean generateAsSerializable)

This will set whether or not to set source code classes as serializable (implementing java.io.Serializable.

Parameters:
generateAsSerializable - boolean indicating whether to generate the source code as serializable.

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.

Parameters:
interfacePackage - String the Java package to generate interfaces within.

setNamePrefix

public void setNamePrefix(java.lang.String namePrefix)

This method allows the developer to set a prefix that will be prepended to the name of every generated interface and class.

Parameters:
String - prefix that will be prepended to the name of every generated interface and class

setCollapseSimpleElements

public void setCollapseSimpleElements(boolean collapseSimpleElements)

This method allows the developer to specify that all simple XML elements (elements with #PCDATA content) should map to data members on parent member classes rather than their own classes.

Parameters:
collapseSimpleElements - true if simple elements should be collapsed

generate

public void generate()
              throws java.io.IOException

This method performs class generation.

Throws:
IOException - - when class generation fails

getConstraintBindings

protected abstract java.util.List getConstraintBindings()
                                                 throws java.io.IOException

This defines a contract for subclasses to allow them to get the Zeus Binding objects to generate code from.

Returns:
List - a list of the Binding objects to generate code from.
Throws:
IOException - - when binding creation fails


Copyright © 2001 Enhydra. All Rights Reserved.