|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.zeus.generator.SimpleGenerator
is the portion of Zeus that will convert
a set of constraints, visible through a Generator
,
and output them as generated Java classes (to a
Binding
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.
Field Summary | |
protected java.util.List |
collapsedElements
This instances's collapsed elements |
protected java.util.List |
globalImplementationImports
A list of classes to import for all implementations |
protected java.util.List |
globalInterfaceImports
A list of classes to import for all interfaces |
protected java.util.List |
globalUnmarshallerImports
A list of classes to import for all unmarshallers |
protected java.util.List |
ignoredBindings
A list of bindings to ignore |
protected boolean |
initialized
Keeps track of whether the Generator needs to be reinitialized. |
protected java.io.File |
outputDir
Base directory for generated files. |
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. |
protected void |
generateImplementation(Container container)
This will generate the implementation (or implemenations, through recursion) for the supplied Container . |
protected void |
generateInterface(Container container)
This will generate the interface (or interfaces, through recursion) for the supplied Container . |
protected void |
generatePrimitiveAssignment(java.io.Writer writer,
Property property,
java.lang.String value)
This method will write to the writer an expression that evaluates to the value of the string value, but as the type of the property. |
protected void |
generateUnmarshallableInterface(Container container)
This will generate the Unmarshallable interface for use
by generated classes in the unmarshalling process. |
protected void |
generateUnmarshaller(Container container)
This will generate the Unmarshaller class for this
container, which calls out to the implementation class for
static unmarshalling from XML to Java. |
protected boolean |
isIgnoredBinding(java.lang.String xmlName,
java.lang.String xmlNamespaceURI)
This will determine if a particular binding should be ignored. |
void |
setIgnoreBinding(java.lang.String xmlName)
This allows a binding to be ignored. |
void |
setIgnoreBinding(java.lang.String xmlName,
java.lang.String xmlNamespaceURI)
This allows a binding to be ignored. |
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. |
protected void |
writeDefaultErrorHandler(java.io.Writer writer,
Container container)
This will write out the default error handler for use when validation is on, and no ErrorHandler implementation is provided. |
protected void |
writeImplementationConstructor(java.io.Writer writer,
java.lang.String className,
java.util.List properties)
This writes out the constructor for an implementation class |
protected void |
writeImplementationDeclaration(java.io.Writer writer,
java.lang.String interfaceName)
This writes out the implementation declaration (the class header). |
protected void |
writeImplementationImportStatements(java.io.Writer writer,
java.util.List importClasses)
This will take the supplied list of class names, and add import statements for each of the classes in the list. |
protected void |
writeImplementationMarshalMethods(java.io.Writer writer,
Container container)
This will write out the implementation of the various marshal . |
protected void |
writeImplementationMethods(java.io.Writer writer,
Container container)
This writes out the properties for an implementation as methods, including accessors, mutators, and collection-style methods if needed. |
protected void |
writeImplementationProperties(java.io.Writer writer,
java.util.List properties)
This writes out the properties for an implementation as variables. |
protected void |
writeImplementationPrototypeMethodAndField(java.io.Writer writer,
java.lang.String className)
This writes out the prototype field and methods for an implementation class |
protected void |
writeImplementationSAXHandlerMethods(java.io.Writer writer,
Container container)
This will write out methods that implements various SAX handlers for use in unmarshalling. |
protected void |
writeImplementationUnmarshallerProperties(java.io.Writer writer,
Container container)
This will write out properties required for unmarshalling from XML into this Java class. |
protected void |
writeImplementationUnmarshalMethods(java.io.Writer writer,
Container container)
This will write out the implementation of the various unmarshal methods supported by generated classes. |
protected void |
writeInterfaceDeclaration(java.io.Writer writer,
Container container)
This writes out the interface declaration (the class header). |
protected void |
writeInterfaceImportStatements(java.io.Writer writer,
java.util.List importClasses)
This will take the supplied list of class names, and add import statements for each of the classes in the list. |
protected void |
writeInterfaceMarshalMethods(java.io.Writer writer)
This will write out the declaration of the various marshal
methods supported by generated classes. |
protected void |
writeInterfaceMethods(java.io.Writer writer,
java.util.List properties)
This writes out the various method declarations for an interface. |
protected void |
writePackageDeclaration(java.io.Writer writer,
java.lang.String packageName)
This writes out the package declaration for this class, if needed. |
protected void |
writeProperty(java.io.Writer writer,
Property property)
This will take a Property and generate the code
for that property as a member variable. |
protected void |
writePropertyMethodDecl(java.io.Writer writer,
Property property)
This will take a Property and generate the code
for that property as an accessor/mutator method (definition only). |
protected void |
writePropertyMethodImplementation(java.io.Writer writer,
Property property)
This will take a Property and generate the code
for that property as an accessor/mutator method (with implementation). |
protected void |
writeUnmarshallerDeclaration(java.io.Writer writer,
Container container)
This writes out the unmarshaller declaration (the class header). |
protected void |
writeUnmarshallerImportStatements(java.io.Writer writer,
java.util.List importClasses)
This will take the supplied list of class names, and add import statements for each of the classes in the list. |
protected void |
writeUnmarshallerProperties(java.io.Writer writer,
Container container)
This will write out the unmarshaller properties. |
protected void |
writeUnmarshallerUnmarshalMethods(java.io.Writer writer,
Container container)
This will write out the unmarshaller version of the various unmarshal methods supported by generated classes. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.List ignoredBindings
protected java.util.List globalUnmarshallerImports
protected java.util.List globalInterfaceImports
protected java.util.List globalImplementationImports
protected java.util.List collapsedElements
protected java.io.File outputDir
protected boolean initialized
Constructor Detail |
public SimpleGenerator()
This will construct a new instance of SimpleGenerator
.
Method Detail |
public void setOutputDirectory(java.lang.String outputDir)
This sets the output directory to output generated classes to.
setOutputDirectory
in interface Generator
baseDir
- the name of the base directory where
all generated classes should be placedpublic void setOutputDirectory(java.io.File outputDir)
This sets the output directory to output generated classes to.
setOutputDirectory
in interface Generator
outputDir
- the File
(directory) where
all generated classes should be placedpublic void setIgnoreBinding(java.lang.String xmlName, java.lang.String xmlNamespaceURI)
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.
setIgnoreBinding
in interface Generator
xmlName
- the XML local name of the binding to ignore.xmlNamespaceURI
- the XML namespace URI of the binding to ignore.
The empty string indicates there is no namespace associated
with the binding.public void setIgnoreBinding(java.lang.String xmlName)
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. This convenience version supplies an empty string for the namespace URI.
setIgnoreBinding
in interface Generator
xmlName
- the XML local name of the binding to ignore.protected boolean isIgnoredBinding(java.lang.String xmlName, java.lang.String xmlNamespaceURI)
xmlName
- the XML local name of the binding.xmlNamespaceURI
- the XML namespace URI associated with the binding.
An empty string indicates that there is no namespace associated
with the binding.public void generate(Binding binding) throws java.io.IOException, ZeusException
This will convert from a set of constraints to Java classes.
It accesses those constraints through the
interface, which provides
them in a representation-independent format, and then
converts them into Java code.
Binding
generate
in interface Generator
binder
- Binder
with ability to convert from
constraints to Zeus Binding
s.root
- whether this is the root elementIOException
- - when errors in writing to the
supplied Result
occur.ZeusException
- - when errors in class generation
occur.protected void generateUnmarshaller(Container container) throws java.io.IOException
This will generate the Unmarshaller
class for this
container, which calls out to the implementation class for
static unmarshalling from XML to Java.
container
- Container
to generate classes from.IOException
- - when generation errors occur.protected void generateUnmarshallableInterface(Container container) throws java.io.IOException
This will generate the Unmarshallable
interface for use
by generated classes in the unmarshalling process.
container
- Container
to generate classes from.IOException
- - when generation errors occur.protected void generateInterface(Container container) throws java.io.IOException
This will generate the interface (or interfaces, through recursion)
for the supplied Container
.
container
- Container
to generate classes from.IOException
- - when generation errors occur.protected void generateImplementation(Container container) throws java.io.IOException
This will generate the implementation (or implemenations, through
recursion) for the supplied Container
.
container
- Container
to generate classes from.IOException
- - when generation errors occur.protected void writePackageDeclaration(java.io.Writer writer, java.lang.String packageName) throws java.io.IOException
This writes out the package declaration for this class, if needed.
writer
- Writer
to perform output topackageName
- the package of this classIOException
- - when errors in output occur.protected void writeUnmarshallerImportStatements(java.io.Writer writer, java.util.List importClasses) throws java.io.IOException
This will take the supplied list of class names, and add import statements for each of the classes in the list. It will also write out all global import statements for unmarshaller classes.
writer
- Writer
to output toimportClasses
- List
of classes to add imports forIOException
- - when errors in output occur.protected void writeUnmarshallerDeclaration(java.io.Writer writer, Container container) throws java.io.IOException
This writes out the unmarshaller declaration (the class header).
writer
- Writer
to output tocontainer
- the container for the classIOException
- - when errors in output occur.protected void writeUnmarshallerProperties(java.io.Writer writer, Container container) throws java.io.IOException
This will write out the unmarshaller properties.
writer
- Writer
to output tocontainer
- the container to write the unmarshalling for.IOException
- - when errors in output occur.protected void writeUnmarshallerUnmarshalMethods(java.io.Writer writer, Container container) throws java.io.IOException
This will write out the unmarshaller version of the various
unmarshal
methods supported by generated classes.
writer
- Writer
to output tocontainer
- the container to write the unmarshalling for.IOException
- - when errors in output occur.protected void writeDefaultErrorHandler(java.io.Writer writer, Container container) throws java.io.IOException
This will write out the default error handler for use when validation
is on, and no ErrorHandler
implementation is provided.
writer
- Writer
to output to.container
- the container this error handler is for.IOException
- - when errors in output occur.protected void writeInterfaceImportStatements(java.io.Writer writer, java.util.List importClasses) throws java.io.IOException
This will take the supplied list of class names, and add import statements for each of the classes in the list. It will also write out all global import statements for interface classes.
writer
- Writer
to output toimportClasses
- List
of classes to add imports forIOException
- - when errors in output occur.protected void writeInterfaceDeclaration(java.io.Writer writer, Container container) throws java.io.IOException
This writes out the interface declaration (the class header).
writer
- Writer
to output tocontainer
- the container to write the interface for.IOException
- - when errors in output occur.protected void writeInterfaceMethods(java.io.Writer writer, java.util.List properties) throws java.io.IOException
This writes out the various method declarations for an interface.
writer
- Writer
to output toproperties
- List
of properties to write out method
declarations forIOException
- - when errors in output occur.protected void writePropertyMethodDecl(java.io.Writer writer, Property property) throws java.io.IOException
This will take a Property
and generate the code
for that property as an accessor/mutator method (definition only).
writer
- Writer
to write method declarations to.property
- Property
to generate methods for.IOException
- - when errors in writing to the
supplied Result
occur.protected void writeInterfaceMarshalMethods(java.io.Writer writer) throws java.io.IOException
This will write out the declaration of the various marshal
methods supported by generated classes.
writer
- Writer
to output toIOException
- - when errors in output occur.protected void writeImplementationImportStatements(java.io.Writer writer, java.util.List importClasses) throws java.io.IOException
This will take the supplied list of class names, and add import statements for each of the classes in the list. It will also write out all global import statements for implementation classes.
writer
- Writer
to output toimportClasses
- List
of classes to add imports forIOException
- - when errors in output occur.protected void writeImplementationDeclaration(java.io.Writer writer, java.lang.String interfaceName) throws java.io.IOException
This writes out the implementation declaration (the class header).
writer
- Writer
to output tointerfaceName
- the name of the interface class being implementedIOException
- - when errors in output occur.protected void writeImplementationProperties(java.io.Writer writer, java.util.List properties) throws java.io.IOException
This writes out the properties for an implementation as variables.
writer
- Writer
to output toproperties
- List
of properties to write out as
member variablesIOException
- - when errors in output occur.protected void writeProperty(java.io.Writer writer, Property property) throws java.io.IOException
This will take a Property
and generate the code
for that property as a member variable.
writer
- Writer
to write variable declaration to.property
- Property
to generate code for.IOException
- - when errors in writing to the
supplied Result
occur.protected void writeImplementationUnmarshallerProperties(java.io.Writer writer, Container container) throws java.io.IOException
This will write out properties required for unmarshalling from XML into this Java class.
writer
- Writer
to output tocontainer
- the container writing out forIOException
- - when errors in output occur.protected void writeImplementationPrototypeMethodAndField(java.io.Writer writer, java.lang.String className) throws java.io.IOException
This writes out the prototype field and methods for an implementation class
writer
- Writer
to output toclassName
- the name of the implementation classproperties
- List
of properties to write out as
member variablesIOException
- - when errors in output occur.protected void writeImplementationConstructor(java.io.Writer writer, java.lang.String className, java.util.List properties) throws java.io.IOException
This writes out the constructor for an implementation class
writer
- Writer
to output toclassName
- the name of the implementation classproperties
- List
of properties to write out as
member variablesIOException
- - when errors in output occur.protected void writeImplementationMethods(java.io.Writer writer, Container container) throws java.io.IOException
This writes out the properties for an implementation as methods, including accessors, mutators, and collection-style methods if needed.
writer
- Writer
to output tocontainer
- Container
with properties to generate
methods forIOException
- - when errors in output occur.protected void writePropertyMethodImplementation(java.io.Writer writer, Property property) throws java.io.IOException
This will take a Property
and generate the code
for that property as an accessor/mutator method (with implementation).
writer
- Writer
to write method implementations to.property
- Property
to generate code for.IOException
- - when errors in writing to the
supplied Result
occur.protected void writeImplementationMarshalMethods(java.io.Writer writer, Container container) throws java.io.IOException
This will write out the implementation of the various
marshal
. methods supported by generated classes.
writer
- Writer
to output toIOException
- - when errors in output occur.protected void writeImplementationUnmarshalMethods(java.io.Writer writer, Container container) throws java.io.IOException
This will write out the implementation of the various
unmarshal
methods supported by generated classes.
writer
- Writer
to output tocontainer
- the container to write methods for.IOException
- - when errors in output occur.protected void writeImplementationSAXHandlerMethods(java.io.Writer writer, Container container) throws java.io.IOException
This will write out methods that implements various SAX handlers for use in unmarshalling.
writer
- Writer
to output tocontainer
- the container to write class for.IOException
- - when errors in output occur.protected void generatePrimitiveAssignment(java.io.Writer writer, Property property, java.lang.String value) throws java.io.IOException
This method will write to the writer an expression that evaluates to the value of the string value, but as the type of the property. Only use this if the property has a primitive Java type.
writer
- the output writerproperty
- the property that defines the primitive typevalue
- the string value for the primitive (i.e. "true" for boolean
or "1.8" for float)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |