org.enhydra.zeus.transform
Class BaseTransformer

java.lang.Object
  |
  +--org.enhydra.zeus.transform.BaseTransformer
All Implemented Interfaces:
Transformer
Direct Known Subclasses:
SimpleTransformer

public abstract class BaseTransformer
extends java.lang.Object
implements Transformer

Transformer is the interface for converting a set of Zeus Binding objects from a set of XML-based names and identities (created by a Zeus Binder instance) to another set of Binding objects. This second set of objects is only an intermediate set, which is then used by a Generator to create Java classes.

This allows a user to specify a mapping file and thereby transform a set of XML names into another set of names, either for ensuring legal Java names, for using more business-centric names, or any other user desired basis.

BaseTransformer is an abstract, base implementation of Transformer, and provides common functionality. All Transformer implementations should extend this base class.

Author:
Brett McLaughlin

Field Summary
protected  Source source
          The Source to read mapping information from
 
Constructor Summary
BaseTransformer(Source source)
           This constructor takes in a Source to read mapping information from and allow generation of the transformation mappings from it.
 
Method Summary
 void addValueEnumeration(ValueEnumeration valueEnumeration)
           This will add a new ValueEnumeration to those available to this Transformer.
 TransformerOptions getTransformerOptions()
           This returns the current TransformerOptions for this transformer.
 ValueEnumeration getValueEnumeration(java.lang.String name)
           This will retrieve the ValueEnumeration for the supplied name.
 void setTransformerOptions(TransformerOptions transformerOptions)
           This allows setting of the TransformerOptions for this transformer.
 java.util.List transform(java.util.List bindings)
           This method performs the work of transforming a set of Zeus Binding objects.
abstract  java.util.List transform(java.util.List bindings, boolean recursing)
           This method performs the work of transforming a set of Zeus Binding objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

protected Source source
The Source to read mapping information from
Constructor Detail

BaseTransformer

public BaseTransformer(Source source)

This constructor takes in a Source to read mapping information from and allow generation of the transformation mappings from it.

Parameters:
source - Source to read mapping input from.
Method Detail

setTransformerOptions

public void setTransformerOptions(TransformerOptions transformerOptions)

This allows setting of the TransformerOptions for this transformer.

Specified by:
setTransformerOptions in interface Transformer
Parameters:
transformerOptions - the options for this transformer

getTransformerOptions

public TransformerOptions getTransformerOptions()

This returns the current TransformerOptions for this transformer.

Specified by:
getTransformerOptions in interface Transformer
Returns:
TransformerOptions - the options in use for this transformer.

addValueEnumeration

public void addValueEnumeration(ValueEnumeration valueEnumeration)

This will add a new ValueEnumeration to those available to this Transformer.

Specified by:
addValueEnumeration in interface Transformer
Parameters:
valueEnumeration - the enumeration to add for this transformer.

getValueEnumeration

public ValueEnumeration getValueEnumeration(java.lang.String name)
                                     throws NoSuchValueEnumerationException

This will retrieve the ValueEnumeration for the supplied name.

If the supplied name is not associated with a ValueEnumeration, this is considered an exceptional condition; any Transformer construct looking for a ValueEnumeration by name expects to find one, or the supplied mapping information is in error. Therefore, in this case, a NoSuchValueEnumerationException is thrown.

Specified by:
getValueEnumeration in interface Transformer
Returns:
ValueEnumeration - the enumeration for the supplied name.
Throws:
NoSuchValueEnumerationException - - when an enumeration with the supplied name cannot be found.

transform

public java.util.List transform(java.util.List bindings)
                         throws java.io.IOException,
                                ZeusException

This method performs the work of transforming a set of Zeus Binding objects. It then returns a new set of Binding objects (in List form) with transformed names, types, and values.

When this method is invoked, it attempts to see if parsing of the mapping file has already occurred. If it has not, parsing of that file will occur within this method.

It is important to note that the number of bindings returned from this method may not be the same as the number supplied. This is due to some XML elements/attributes being converted to value objects, while other mapping instructions may actually create new binding objects.

Specified by:
transform in interface Transformer
Parameters:
bindings - List of bindings to process for transformation.
Returns:
List - the transformed bindings.
Throws:
IOException - - when errors occur in parsing a mapping configuration file.
ZeusException - - when errors occuring in transformation.

transform

public abstract java.util.List transform(java.util.List bindings,
                                         boolean recursing)
                                  throws java.io.IOException,
                                         ZeusException

This method performs the work of transforming a set of Zeus Binding objects. It then returns a new set of Binding objects (in List form) with transformed names, types, and values.

When this method is invoked, it attempts to see if parsing of the mapping file has already occurred. If it has not, parsing of that file will occur within this method.

It is important to note that the number of bindings returned from this method may not be the same as the number supplied. This is due to some XML elements/attributes being converted to value objects, while other mapping instructions may actually create new binding objects.

Parameters:
bindings - List of bindings to process for transformation.
recursing - indication of if this is within a recursion loop.
Returns:
List - the transformed bindings.
Throws:
IOException - - when errors occur in parsing a mapping configuration file.
ZeusException - - when errors occuring in transformation.


Copyright © 2002 Enhydra. All Rights Reserved.