org.joone.util
Class AbstractConverterPlugIn

java.lang.Object
  extended by org.joone.util.AbstractConverterPlugIn
All Implemented Interfaces:
java.io.Serializable, PlugInListener
Direct Known Subclasses:
ConverterPlugIn, OutputConverterPlugIn

public abstract class AbstractConverterPlugIn
extends java.lang.Object
implements java.io.Serializable, PlugInListener

This abstract class must be extended to implement plug-ins for input or output data pre- or post-processing.

Author:
Boris Jansen
See Also:
Serialized Form

Field Summary
protected  java.util.Vector pluginListeners
          A vector of objects that are listening to this object for plug-in (data changed) events.
 
Constructor Summary
AbstractConverterPlugIn()
          Creates a new instance of AbstractConverterPlugIn
AbstractConverterPlugIn(java.lang.String anAdvancedSerieSelector)
          Creates a new instance of AbstractConverterPlugIn
 
Method Summary
 boolean addPlugIn(AbstractConverterPlugIn aNewPlugIn)
          Adds a plug-in at the end of the list of plug-ins.
 void addPlugInListener(PlugInListener aListener)
          Adds an PlugInListener to this plug-in.
protected  boolean apply()
          Applies all the conversions on the patterns contained by InputVector
protected  boolean applyOnColumns()
          Applies the conversion on the patterns contained by InputVector and on the columns specifed by the call to setAdvancedSerieSelector#setAdvancedSerieSelector.
protected  boolean applyOnRows()
          Applies the conversion on the patterns contained by InputVector on all the rows.
protected  void cascade()
          Cascades the convertPatterns() method call to the next plug-in.
 java.util.TreeSet check(java.util.TreeSet checks)
          This method is called to perform a check on this converter's properties to ensure there are no errors or problems.
protected abstract  boolean convert(int serie)
          Applies the conversion on the Nth serie of the buffered pattern data.
 void convertPatterns()
          Converts all the patterns contained by InputVector and on the serie specifed by the call to setAdvancedSerieSelector#setAdvancedSerieSelector.
 void dataChanged(PlugInEvent anEvent)
          This method is called by plug-ins whenever data is changed.
protected  void fireDataChanged()
          Fires a data changed event to all PlugInListeners that are registered to receive events from this plug-in object.
 java.lang.String getAdvancedSerieSelector()
          Gets the AdvancedSerieSelector.
protected  java.util.Vector getInputVector()
          Gets the input vector of Patterns with which this converter must process.
 java.lang.String getName()
          Gets the name of this plug-in object.
 AbstractConverterPlugIn getNextPlugIn()
          Gets the next converter plug-in within this cascading series of plug-ins.
protected  java.util.Vector getPluginListeners()
          Gets a vector of all the PlugInListeners that have been registerd to receive events from this plug-in.
protected  int getSerieIndexNumber(int serie)
          Gets the index of the current serie number.
protected  int[] getSerieSelected()
          Getter for property serieSelected.
protected  double getValuePoint(int point, int serie)
          Gets the double value at the specified row (point) in the specifed serie / column.
 boolean isConnected()
          Getter for property connected.
 void removeAllPlugIns()
          Removes (and disconnects) all (cascading) plug ins.
 void removePlugInListener(PlugInListener aListener)
          Removes a PlugInListener that was previously registered to receive plugin (data changed) events.
 void setAdvancedSerieSelector(java.lang.String aNewSerieSelector)
          Sets the AdvancedSerieSelector for this plugin.
 void setConnected(boolean aConnected)
          Setter for property connected.
 void setInputVector(java.util.Vector newInputVector)
          Sets the input vector of Patterns that this converter plugin should process.
 void setName(java.lang.String aName)
          Sets the name of this plug-in object.
 boolean setNextPlugin(AbstractConverterPlugIn aNewNextPlugIn)
          Deprecated. addPlugIn(AbstractConverterPlugIn)
 void setNextPlugIn(AbstractConverterPlugIn newNextPlugIn)
          Added for XML serialization
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pluginListeners

protected java.util.Vector pluginListeners
A vector of objects that are listening to this object for plug-in (data changed) events.

Constructor Detail

AbstractConverterPlugIn

public AbstractConverterPlugIn()
Creates a new instance of AbstractConverterPlugIn


AbstractConverterPlugIn

public AbstractConverterPlugIn(java.lang.String anAdvancedSerieSelector)
Creates a new instance of AbstractConverterPlugIn

Parameters:
anAdvancedSerieSelector - the advanced serie selector to use.
See Also:
setAdvancedSerieSelector()
Method Detail

convertPatterns

public void convertPatterns()
Converts all the patterns contained by InputVector and on the serie specifed by the call to setAdvancedSerieSelector#setAdvancedSerieSelector. It cascades also the conversion to the next-plugin connected in the chain.


apply

protected boolean apply()
Applies all the conversions on the patterns contained by InputVector

Returns:
true if the input buffer is changed

applyOnColumns

protected boolean applyOnColumns()
Applies the conversion on the patterns contained by InputVector and on the columns specifed by the call to setAdvancedSerieSelector#setAdvancedSerieSelector.


applyOnRows

protected boolean applyOnRows()
Applies the conversion on the patterns contained by InputVector on all the rows. Override this empty method to apply any change to the order of the input vector's rows.


cascade

protected void cascade()
Cascades the convertPatterns() method call to the next plug-in.


convert

protected abstract boolean convert(int serie)
Applies the conversion on the Nth serie of the buffered pattern data. The method is abstract and should be overridden by the implementing class. Implementing classes can obtain the input patterns by calling the getInputVector() method. The result is a Vector of Pattern objects which this method should use by converting the requested serie.

Parameters:
serie - the serie to convert

getValuePoint

protected double getValuePoint(int point,
                               int serie)
Gets the double value at the specified row (point) in the specifed serie / column.

Parameters:
point - The row at which to get the pattern's double value.
serie - The serie or column from which to obtain the value.
Returns:
The value at the specified point in the input vector.

getName

public java.lang.String getName()
Gets the name of this plug-in object.

Returns:
The name of this plug-in.

setName

public void setName(java.lang.String aName)
Sets the name of this plug-in object.

Parameters:
aName - New name for this object.

isConnected

public boolean isConnected()
Getter for property connected. This property is true when this plugin has been attached either to a StreamInputSynapse or to another plugin.

Returns:
Value of property connected.

setConnected

public void setConnected(boolean aConnected)
Setter for property connected. This property is true when this plugin has been attached either to a StreamInputSynapse or to another plugin.

Parameters:
aConnected - New value of property connected.

addPlugInListener

public void addPlugInListener(PlugInListener aListener)
Adds an PlugInListener to this plug-in. Usually this will be the previous plug-in in the series of cascading plug-ins or the stream input/output synapse.

Parameters:
aListener - The listener that requires notification of events from this plug-in whenever data changes.

removePlugInListener

public void removePlugInListener(PlugInListener aListener)
Removes a PlugInListener that was previously registered to receive plugin (data changed) events.

Parameters:
aListener - The listener that does not want to receive any events anymore from this plug-in.

getPluginListeners

protected java.util.Vector getPluginListeners()
Gets a vector of all the PlugInListeners that have been registerd to receive events from this plug-in.

Returns:
The vector of PlugInListeners listening to this converter plug-in object.

dataChanged

public void dataChanged(PlugInEvent anEvent)
Description copied from interface: PlugInListener
This method is called by plug-ins whenever data is changed.

Specified by:
dataChanged in interface PlugInListener
Parameters:
anEvent - the event that is send, i.e. the event indicating that the data is changed.

fireDataChanged

protected void fireDataChanged()
Fires a data changed event to all PlugInListeners that are registered to receive events from this plug-in object. This method calls the InputPlugInListener#dataChanged() method in all registered listeners.


getAdvancedSerieSelector

public java.lang.String getAdvancedSerieSelector()
Gets the AdvancedSerieSelector.

Returns:
Value of property AdvancedSerieSelector.

setAdvancedSerieSelector

public void setAdvancedSerieSelector(java.lang.String aNewSerieSelector)
Sets the AdvancedSerieSelector for this plugin.

The AdvancedSerieSelector instructs this plug-in what serie/columns it should process. The format of this specification is a common seperated list of values and ranges. E.g '1,2,5,7' will instruct the converter to convert serie 1 and 2 and 5 and 7. A range can also be used e.g '2,4,5-8,9' will instruct the converter to process serie 2 and 4 and 5 and 6 and 7 and 8 and 9. A range is specifed using a '-' character with the number of the serie on either side.

Note NO negative numbers can be used in the AdvancedSerieSelector.

Parameters:
aNewSerieSelector - New value for the AdvancedSerieSelector.

getSerieSelected

protected int[] getSerieSelected()
Getter for property serieSelected. Returns the list of selected columns to elaborate.

Returns:
Value of property serieSelected.

addPlugIn

public boolean addPlugIn(AbstractConverterPlugIn aNewPlugIn)
Adds a plug-in at the end of the list of plug-ins.

Parameters:
aNewPlugIn - the new plug in to add at the end of plug ins.
Returns:
true when the plug in is added succesfully, false when the plug in is not added, e.g. in case the plug in is already added / connected to another synapse / plug-in.

removeAllPlugIns

public void removeAllPlugIns()
Removes (and disconnects) all (cascading) plug ins.


setNextPlugin

public boolean setNextPlugin(AbstractConverterPlugIn aNewNextPlugIn)
Deprecated. addPlugIn(AbstractConverterPlugIn)

Sets the next plug-in in a cascading series of plugins.

Parameters:
aNewNextPlugIn - The next plug-in in the series.
Returns:
true when the plug-in is successfully added, false otherwise.

getNextPlugIn

public AbstractConverterPlugIn getNextPlugIn()
Gets the next converter plug-in within this cascading series of plug-ins.

Returns:
the next plug-in within this cascading series of plug-ins.

setNextPlugIn

public void setNextPlugIn(AbstractConverterPlugIn newNextPlugIn)
Added for XML serialization

**** DO NOT USE ****

Use addPlugIn(AbstractConverterPlugIn)


setInputVector

public void setInputVector(java.util.Vector newInputVector)
Sets the input vector of Patterns that this converter plugin should process.

Parameters:
newInputVector - The vector of Pattern objects to process.

getInputVector

protected java.util.Vector getInputVector()
Gets the input vector of Patterns with which this converter must process.

Returns:
the vector with patterns that this converter processes.

check

public java.util.TreeSet check(java.util.TreeSet checks)
This method is called to perform a check on this converter's properties to ensure there are no errors or problems. If there is an error or problem with one of the properties then the issues are returned in a TreeSet object.

Parameters:
checks - A TreeSet of issues that should be added to by this plug-in.
Returns:
A TreeSet of errors or problems relating to the setup of this converter plug-in object.
See Also:
Synapse

getSerieIndexNumber

protected int getSerieIndexNumber(int serie)
Gets the index of the current serie number.

Returns:
int -1 if the serie could not be found in the serie specification.


Submit Feedback to pmarrone@users.sourceforge.net