Package org.biojava.utils
Class ChangeForwarder
java.lang.Object
org.biojava.utils.ChangeForwarder
- All Implemented Interfaces:
EventListener
,ChangeListener
- Direct Known Subclasses:
AbstractSymbolList.EditScreener
,Annotatable.AnnotationForwarder
,ChangeForwarder.Retyper
,Distribution.NullModelForwarder
,MergeAnnotation.PropertyForwarder
,OverlayAnnotation.PropertyForwarder
,PairwiseSequenceRenderer.PairwiseRendererForwarder
,SequenceDBWrapper.SequencesForwarder
,SequenceRenderer.RendererForwarder
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
- Author:
- Matthew Pocock
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A ChangeForwarder that systematically uses a given type and wraps the old event.Nested classes/interfaces inherited from interface org.biojava.utils.ChangeListener
ChangeListener.AlwaysVetoListener, ChangeListener.ChangeEventRecorder, ChangeListener.LoggingListener
-
Field Summary
Fields inherited from interface org.biojava.utils.ChangeListener
ALWAYS_VETO, LOG_TO_OUT
-
Constructor Summary
ConstructorsConstructorDescriptionChangeForwarder
(Object source, ChangeSupport changeSupport) Create a new ChangeForwarder for forwarding events. -
Method Summary
Modifier and TypeMethodDescriptionReturn the underlyingChangeSupport
instance that can be used to fireChangeEvent
s and mannage listeners.protected ChangeEvent
Return the new event to represent the originating event ce.Retrieve the 'source' object forChangeEvent
s fired by this forwarder.void
Called when a change has just taken place.void
preChange
(ChangeEvent ce) Called before a change takes place.
-
Constructor Details
-
ChangeForwarder
Create a new ChangeForwarder for forwarding events.- Parameters:
source
- the new source ObjectchangeSupport
- the ChangeSupport managing the listeners
-
-
Method Details
-
getSource
Retrieve the 'source' object forChangeEvent
s fired by this forwarder.- Returns:
- the source Object
-
changeSupport
Return the underlyingChangeSupport
instance that can be used to fireChangeEvent
s and mannage listeners.- Returns:
- the ChangeSupport delegate
-
generateEvent
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
Description copied from interface:ChangeListener
Called before a change takes place.
This is your chance to stop the change by throwing a ChangeVetoException. This method does not indicate that the change will definitely take place, so it is not recomended that you take any positive action within this handler.
- Specified by:
preChange
in interfaceChangeListener
- Parameters:
ce
- An event encapsulating the change which is about to take place.- Throws:
ChangeVetoException
- Description of ExceptionChangeVetoException
- if the receiver does not wish this change to occur at this time.
-
postChange
Description copied from interface:ChangeListener
Called when a change has just taken place.
This method is the place to perform any behavior in response to the change event.
- Specified by:
postChange
in interfaceChangeListener
- Parameters:
ce
- An event encapsulating the change which has occured.
-