org.treebind
Class DefaultPipeImplementation

java.lang.Object
  extended byorg.treebind.DefaultPipeImplementation
All Implemented Interfaces:
Pipe
Direct Known Subclasses:
JavaObject2XmlSaxPipe, JenaRdf2JavaObjectPipe, Ldap2JavaObjectPipe, Ldap2XmlSaxPipe, XmlSax2JavaObjectPipe

public class DefaultPipeImplementation
extends java.lang.Object
implements Pipe

A default implementation of a qbePipe that takes care of the attrs. Pipe elements should be added in the following order: 1) The sink 2) Optionally, one or more filters. The sink will be chained to the first filter, the second one to the first and so on. 3) The source. The source will be chained to the last filter if there is one or to the sink if there is no filter.

Author:
vdv

Constructor Summary
DefaultPipeImplementation()
           
 
Method Summary
 void addFilter(Filter filter)
          Add and chain a filter.
 void addFilterAfterSource(Filter newFilter)
           
 void addFilterBeforeSink(Filter newFilter)
          Add and chain a filter after the first one.
 java.lang.Object getParameter(java.lang.String name)
          Get a parameter from its name.
 java.lang.Object getParameter(java.lang.String name, java.lang.String key)
          Get a parameter from its name and key.
 java.lang.Object getParameterWithDefault(java.lang.String name, java.lang.Object defaultValue)
          Get a parameter with a default value.
 java.lang.Object getParameterWithDefault(java.lang.String name, java.lang.String key, java.lang.Object defaultValue)
          Get a parameter from its name and key with a default value.
 Sink getSink()
           
 Source getSource()
           
 void setParameter(java.lang.String name, java.lang.Object value)
          Sets the value of a parameter identified by a name.
 void setParameter(java.lang.String name, java.lang.String key, java.lang.Object value)
          Sets the value of a parameter identified by a name and a key.
 void setSink(Sink sink)
          Set the sink of the pipe.
 void setSource(Source source)
          Set and chain the source of the pipe.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPipeImplementation

public DefaultPipeImplementation()
Method Detail

addFilter

public void addFilter(Filter filter)
               throws OutOfSyncException
Description copied from interface: Pipe
Add and chain a filter. The sink of the pipe must have been set before this method can be called. The filter is chained to the last filter (or the sink if this is the first filter).

Specified by:
addFilter in interface Pipe
Parameters:
filter - the filter to add.
Throws:
OutOfSyncException - exception thrown if the pipe has no filter and no sink yet.

addFilterAfterSource

public void addFilterAfterSource(Filter newFilter)
Specified by:
addFilterAfterSource in interface Pipe

addFilterBeforeSink

public void addFilterBeforeSink(Filter newFilter)
Description copied from interface: Pipe
Add and chain a filter after the first one. This method can be used to add a filter to an existing pipe that already have its source, filters and sink set. The new filter is added and chained after the

Specified by:
addFilterBeforeSink in interface Pipe
Parameters:
newFilter -

getParameter

public java.lang.Object getParameter(java.lang.String name)
Description copied from interface: Pipe
Get a parameter from its name.

Specified by:
getParameter in interface Pipe
Parameters:
name - the name of the parameter.
Returns:
the parameter or null if there is no parameter for this name.

getParameter

public java.lang.Object getParameter(java.lang.String name,
                                     java.lang.String key)
Description copied from interface: Pipe
Get a parameter from its name and key.

Specified by:
getParameter in interface Pipe
Parameters:
name - the name of the parameter.
key - key of the parameter.
Returns:
the parameter or null if there is no parameter for these name and key.

getParameterWithDefault

public java.lang.Object getParameterWithDefault(java.lang.String name,
                                                java.lang.Object defaultValue)
Description copied from interface: Pipe
Get a parameter with a default value.

Specified by:
getParameterWithDefault in interface Pipe
Parameters:
name - the name of the parameter.
defaultValue - the default value.
Returns:
the parameter or the default value if there is no parameter for this name.

getParameterWithDefault

public java.lang.Object getParameterWithDefault(java.lang.String name,
                                                java.lang.String key,
                                                java.lang.Object defaultValue)
Description copied from interface: Pipe
Get a parameter from its name and key with a default value.

Specified by:
getParameterWithDefault in interface Pipe
Parameters:
name - the name of the parameter.
key - key of the parameter.
defaultValue - the default value.
Returns:
the parameter or the default if there is no parameter for these name and key.

getSink

public Sink getSink()

getSource

public Source getSource()

setParameter

public void setParameter(java.lang.String name,
                         java.lang.Object value)
Description copied from interface: Pipe
Sets the value of a parameter identified by a name.

Specified by:
setParameter in interface Pipe
Parameters:
name - the name of the parameter.
value - its value.

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String key,
                         java.lang.Object value)
Description copied from interface: Pipe
Sets the value of a parameter identified by a name and a key.

Specified by:
setParameter in interface Pipe
Parameters:
name - the name of the parameter.
key - its key.
value - its value.

setSink

public void setSink(Sink sink)
Description copied from interface: Pipe
Set the sink of the pipe. This method must be called first before any filter or source can be added.

Specified by:
setSink in interface Pipe
Parameters:
sink -

setSource

public void setSource(Source source)
               throws OutOfSyncException
Description copied from interface: Pipe
Set and chain the source of the pipe. This method must be called after the sink and all the filters have been added. The last filter (or the sink if the pipe has no filters) is chained to the source.

Specified by:
setSource in interface Pipe
Parameters:
source - the source.
Throws:
OutOfSyncException - exception thrown if the pipe has no filter and no sink yet.