org.jscience.util
Class ChangeForwarder

java.lang.Object
  extended by org.jscience.util.ChangeForwarder
All Implemented Interfaces:
java.util.EventListener, ChangeListener
Direct Known Subclasses:
ChangeForwarder.Retyper

public class ChangeForwarder
extends java.lang.Object
implements ChangeListener

This is a ChangeListener that is designed to adapt events of one type from one source to events of another type emitted by another source. For example, you could adapt events made by edits in a database to being events fired by a sequence implementation.

Since:
1.1

Nested Class Summary
static class ChangeForwarder.Retyper
          A ChangeForwarder that systematically uses a given type and wraps the old event.
 
Nested classes/interfaces inherited from interface org.jscience.util.ChangeListener
ChangeListener.AlwaysVetoListener, ChangeListener.LoggingListener
 
Field Summary
 
Fields inherited from interface org.jscience.util.ChangeListener
ALWAYS_VETO, LOG_TO_OUT
 
Constructor Summary
ChangeForwarder(java.lang.Object source, ChangeSupport changeSupport)
          Create a new ChangeForwarder for forwarding events.
 
Method Summary
 ChangeSupport changeSupport()
          Return the underlying ChangeSupport instance that can be used to fire ChangeEvents and mannage listeners.
protected  ChangeEvent generateEvent(ChangeEvent ce)
          

Return the new event to represent the originating event ce.

 java.lang.Object getSource()
          Retrieve the 'source' object for ChangeEvents fired by this forwarder.
 void postChange(ChangeEvent ce)
          DOCUMENT ME!
 void preChange(ChangeEvent ce)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangeForwarder

public ChangeForwarder(java.lang.Object source,
                       ChangeSupport changeSupport)
Create a new ChangeForwarder for forwarding events.

Parameters:
source - the new source Object
changeSupport - the ChangeSupport managing the listeners
Method Detail

getSource

public java.lang.Object getSource()
Retrieve the 'source' object for ChangeEvents fired by this forwarder.

Returns:
the source Object

changeSupport

public ChangeSupport changeSupport()
Return the underlying ChangeSupport instance that can be used to fire ChangeEvents and mannage listeners.

Returns:
the ChangeSupport delegate

generateEvent

protected ChangeEvent generateEvent(ChangeEvent ce)
                             throws ChangeVetoException

Return the new event to represent the originating event ce.

The returned ChangeEvent is the event that will be fired, and should be built from information in the original event. If it is null, then no event will be fired.

The default implementation just constructs a ChangeEvent of the same type that chains back to ce.

Parameters:
ce - the originating ChangeEvent
Returns:
a new ChangeEvent to pass on, or null if no event should be sent
Throws:
ChangeVetoException - if for any reason this event can't be handled

preChange

public void preChange(ChangeEvent ce)
               throws ChangeVetoException
DOCUMENT ME!

Specified by:
preChange in interface ChangeListener
Parameters:
ce - DOCUMENT ME!
Throws:
ChangeVetoException - DOCUMENT ME!

postChange

public void postChange(ChangeEvent ce)
DOCUMENT ME!

Specified by:
postChange in interface ChangeListener
Parameters:
ce - DOCUMENT ME!