org.enhydra.zeus.binder
Class BaseBinder

java.lang.Object
  |
  +--org.enhydra.zeus.binder.BaseBinder
All Implemented Interfaces:
Binder
Direct Known Subclasses:
DTDBinder, SchemaBinder

public abstract class BaseBinder
extends java.lang.Object
implements Binder

Binder provides an interface for all constraint representations to use. It defines the contract for conversion between an arbitrary constraint representation (XML Schema, DTD, Relax schema, etc) to a set of Zeus Bindings.

This implementation of Binder handles the basic functionality of dealing with input so that other implementations don't have to code these methods. Thus, XXXBinder classes should extend this class, rather than directly implementing Binder, and will get this functionality "for free."

Version:
1.0
Author:
Brett McLaughlin, Maciej Zawadzki

Field Summary
protected  boolean collapseSimpleElements
          Determines whether simple elements map to data members on parent clases or to their own classes.
protected  java.lang.String namePrefix
          Prefix to be prepended to the name of every generated interface and class.
protected  Source source
          The Source to read input from
 
Constructor Summary
BaseBinder(Source source)
           This constructor takes in a Source to read input from and allow generation of the Bindings from it.
 
Method Summary
abstract  java.util.List getBindings()
           This is integral portion of the Binder.
 java.lang.String getNamePrefix()
           This method allows the developer to get the prefix that will be prepended to the name of every generated interface and class.
 boolean isCollapsingSimpleElements()
           This method allows the developer to determine whether all simple XML elements (elements with #PCDATA content) will be mapped to data members on parent member classes rather than their own classes.
 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 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.
 
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 input from

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.
Constructor Detail

BaseBinder

public BaseBinder(Source source)

This constructor takes in a Source to read input from and allow generation of the Bindings from it.

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

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.

Specified by:
setNamePrefix in interface Binder
Parameters:
String - prefix that will be prepended to the name of every generated interface and class

getNamePrefix

public java.lang.String getNamePrefix()

This method allows the developer to get the prefix that will be prepended to the name of every generated interface and class. Returns an empty string in the case that a prefix is not prepended.

Specified by:
getNamePrefix in interface Binder
Returns:
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.

Specified by:
setCollapseSimpleElements in interface Binder
Parameters:
collapseSimpleElements - true if simple elements should be collapsed

isCollapsingSimpleElements

public boolean isCollapsingSimpleElements()

This method allows the developer to determine whether all simple XML elements (elements with #PCDATA content) will be mapped to data members on parent member classes rather than their own classes.

Specified by:
isCollapsingSimpleElements in interface Binder
Returns:
boolean true if simple elements will be collapsed

getBindings

public abstract java.util.List getBindings()
                                    throws java.io.IOException

This is integral portion of the Binder. It is responsible for returning a Zeus representation of the set of constraints that this binding represents, resulting from the input representation (which could be an XML Schema, DTD, Relax schema, etc.).

There is a temptation to implement a lazy-loading mechanism here, but that should not be done. That's because the Source may stay the same but the actual input (abstracted by the Source may change "under the covers." So don't implement lazy-loading here!

Specified by:
getBindings in interface Binder
Returns:
List - the resultant Bindings from conversion of constraints.
Throws:
IOException - when errors in reading input occur.


Copyright © 2001 Enhydra. All Rights Reserved.