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."

Author:
Brett McLaughlin, Maciej Zawadzki, Sean Ogle

Field Summary
protected  boolean isCollapsingSimpleElements
          Whether or not simple elements are being collapsed.
protected  boolean isIgnoringIDAttributes
          Whether or not ID attributes are ignored
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.
 boolean isCollapsingSimpleElements()
           This will indicate whether simple elements are being collapsed for this binder.
 boolean isIgnoringIDAttributes()
           This will indicate if the id attribute on elements handled by this Binder should be ignored in determine if an element is collapsible.
 void setIsCollapsingSimpleElements(boolean isCollapsingSimpleElements)
           This sets whether or not to "collapse" simple elements.
 void setIsIgnoringIDAttributes(boolean isIgnoringIDAttributes)
           This indicates if the id attribute on elements handled by this Binder should be ignored in determine if an element is collapsible.
 
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

isCollapsingSimpleElements

protected boolean isCollapsingSimpleElements
Whether or not simple elements are being collapsed.

isIgnoringIDAttributes

protected boolean isIgnoringIDAttributes
Whether or not ID attributes are ignored
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

setIsCollapsingSimpleElements

public void setIsCollapsingSimpleElements(boolean isCollapsingSimpleElements)

This sets whether or not to "collapse" simple elements. An element is simple if it only has character-based content, and no attributes. If these are collapsed, then they are not turned into full-fledged Java objects (with only a getValue() method), but instead become properties with primitive return values on their parents. So an element named "display-name" with only textual content could be accessed through it's parent object by invoking getDisplayName() on the parent, instead of getDisplayName().getValue(). By default, elements are not collapsed.

Specified by:
setIsCollapsingSimpleElements in interface Binder
Parameters:
isCollapsingSimpleElements - whether or not to collapse simple elements.

isCollapsingSimpleElements

public boolean isCollapsingSimpleElements()

This will indicate whether simple elements are being collapsed for this binder. An element is simple if it only has character-based content, and no attributes. If these are collapsed, then they are not turned into full-fledged Java objects (with only a getValue() method), but instead become properties with primitive return values on their parents. So an element named "display-name" with only textual content could be accessed through it's parent object by invoking getDisplayName() on the parent, instead of getDisplayName().getValue(). By default, elements are not collapsed.

Specified by:
isCollapsingSimpleElements in interface Binder
Returns:
boolean - whether simple elements are being collapsed.

setIsIgnoringIDAttributes

public void setIsIgnoringIDAttributes(boolean isIgnoringIDAttributes)

This indicates if the id attribute on elements handled by this Binder should be ignored in determine if an element is collapsible. If isCollapsingSimpleElements is false, this has no effect.

Specified by:
setIsIgnoringIDAttributes in interface Binder
Parameters:
ignoringIDAttributes - whether or not to ignore ID attributes.

isIgnoringIDAttributes

public boolean isIgnoringIDAttributes()

This will indicate if the id attribute on elements handled by this Binder should be ignored in determine if an element is collapsible. If isCollapsingSimpleElements is false, this has no effect.

Specified by:
isIgnoringIDAttributes in interface Binder
Returns:
boolean - whether ID attributes are ignored.

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.