Evolvica Core API Version 0.6.2
Last Modified: June 29 2004

org.evolvica.engine
Class AbstractAlgorithm

java.lang.Object
  extended byorg.evolvica.engine.AbstractAlgorithm
All Implemented Interfaces:
IAlgorithm
Direct Known Subclasses:
TemplateAlgorithm

public abstract class AbstractAlgorithm
extends java.lang.Object
implements IAlgorithm

Abstract base class for an algorithm implementation.

Since:
0.4.0
Version:
$Revision: 1.14 $ $Date: 2004/05/26 11:58:21 $
Author:
Andreas Rummler

Field Summary
protected  gnu.trove.THashSet connections
          Connections.
protected  gnu.trove.THashSet elements
          Algorithm elements.
protected  MetadataStore metadata
          The metadata store of this algorithm.
protected  java.lang.String name
          Algorithm name.
protected  IRunner runner
          Algorithm runner.
protected  IValidator validator
          Algorithm validator.
 
Constructor Summary
AbstractAlgorithm()
           
 
Method Summary
 void addElement(IElement element)
          Adds an element to this algorithm.
 void addMetadataChangeListener(java.beans.PropertyChangeListener listener)
          Adds a property change listener that reacts on metadata changes to this algorithm.
 void addOperator(IOperator operator)
          Adds an operator to this algorithm.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a property change listener to this algorithm.
 void connect(IElement source, int output, IElement target, int input)
          Connects two elements.
 void connect(IOperator source, int output, IOperator target)
          Connects two operators.
 void connect(IOperator source, int output, IOperator target, int input)
          Connects two operators.
 void connect(IOperator source, IOperator target)
          Connects two operator.
 void connect(IOperator source, IOperator target, int input)
          Connects two operators.
 int connectionSize()
          Returns the number of connections in this algorithm.
 int elementSize()
          Returns the number of elements contained in this algorithm.
 void execute()
          Executes the algorithm.
 void firePropertyChangeEvent(java.beans.PropertyChangeEvent event)
          Fires a property change event.
 IConnection getConnection(IElement source, int output, IElement target, int input)
          Returns the connection between two elements.
 IConnection getConnection(IOperator source, int output, IOperator target, int input)
          Returns the connection between two operators.
 IElement getElement(IOperator operator)
          Return the algorithm element for a given operator.
 IElement getElementById(java.lang.String id)
          Gets an element by its ID.
 Metadata getMetadata(java.lang.Object source, java.lang.String path)
          Returns a metadata object from the associated metadata store.
 java.lang.String getName()
          Returns the name of the algorithm.
 IRunner getRunner()
          Gets the algorithm runner.
 IValidator getValidator()
          Gets the algorithm validator.
 java.util.Iterator iterateConnections()
          Iterates all connections in this algorithm.
 java.util.Iterator iterateElements()
          Iterates all elements in this algorithm.
 void removeConnection(IConnection connection)
          Removes a connection from this algorithm.
 void removeElement(IElement element)
          Removes an element from this algorithm.
 void removeMetadataChangeListener(java.beans.PropertyChangeListener listener)
          Removes a metadata property change listener from this algorithm.
 void removeOperator(IOperator operator)
          Removes the element for a given operator from this algorithm.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a property change listener from this algorithm.
 void restoreMetadata(IMetadataProvider provider)
          Restores the metadata from the given metadata provider.
 void serializeMetadata(IMetadataSerializer serializer)
          Serializes this algorithm's metadata by using the given serializer.
 void setMetadata(java.lang.Object source, Metadata data)
          Sets a metadata object.
 void setName(java.lang.String string)
          Sets the name of the algorithm.
 void setRunner(IRunner runner)
          Sets a new algorithm runner.
abstract  void setup()
          Sets up the algorithm.
 void setValidator(IValidator validator)
          Sets the algorithm validator.
abstract  void teardown()
          Teardown method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
Algorithm name.


elements

protected gnu.trove.THashSet elements
Algorithm elements.


connections

protected gnu.trove.THashSet connections
Connections.


runner

protected IRunner runner
Algorithm runner.


validator

protected IValidator validator
Algorithm validator.


metadata

protected MetadataStore metadata
The metadata store of this algorithm.

Constructor Detail

AbstractAlgorithm

public AbstractAlgorithm()
Method Detail

addElement

public void addElement(IElement element)
Description copied from interface: IAlgorithm
Adds an element to this algorithm.

Specified by:
addElement in interface IAlgorithm
Parameters:
element - alement to add
See Also:
IAlgorithm.addElement(org.evolvica.engine.IElement)

addOperator

public void addOperator(IOperator operator)
Adds an operator to this algorithm. An algorithm element is created for the given operator and added to this algorithm.

Parameters:
operator - operator to be added

getElement

public IElement getElement(IOperator operator)
Return the algorithm element for a given operator.

Parameters:
operator - operator
Returns:
appropriate algorithm element of null

getElementById

public IElement getElementById(java.lang.String id)
Description copied from interface: IAlgorithm
Gets an element by its ID.

Specified by:
getElementById in interface IAlgorithm
Parameters:
id - id of the element
Returns:
element with the given ID or null
See Also:
IAlgorithm.getElementById(java.lang.String)

iterateElements

public java.util.Iterator iterateElements()
Description copied from interface: IAlgorithm
Iterates all elements in this algorithm.

Specified by:
iterateElements in interface IAlgorithm
Returns:
iterator over all algorithm elements.
See Also:
IAlgorithm.iterateElements()

removeElement

public void removeElement(IElement element)
Description copied from interface: IAlgorithm
Removes an element from this algorithm.

Specified by:
removeElement in interface IAlgorithm
Parameters:
element - element to be removed
See Also:
IAlgorithm.removeElement(org.evolvica.engine.IElement)

removeOperator

public void removeOperator(IOperator operator)
Removes the element for a given operator from this algorithm.

Parameters:
operator - operator to be removed from this algorithm

elementSize

public int elementSize()
Description copied from interface: IAlgorithm
Returns the number of elements contained in this algorithm.

Specified by:
elementSize in interface IAlgorithm
Returns:
number of elements in this algorithm
See Also:
IAlgorithm.elementSize()

connect

public void connect(IOperator source,
                    IOperator target)
Connects two operator. This is a short cut for connect( source, 0, target, 0 ).

Parameters:
source - source operator
target - target operator

connect

public void connect(IOperator source,
                    int output,
                    IOperator target)
Connects two operators. This is a short cut for connect( source, sourceSlot, target, 0 ).

Parameters:
source - source operator
output - output slot
target - target operator

connect

public void connect(IOperator source,
                    IOperator target,
                    int input)
Connects two operators. This is a short cut for connect( source, 0, target, targetSlot ).

Parameters:
source - source operator
target - target operator
input - input slot

connect

public void connect(IOperator source,
                    int output,
                    IOperator target,
                    int input)
Description copied from interface: IAlgorithm
Connects two operators.

Specified by:
connect in interface IAlgorithm
Parameters:
source - source operator
output - source slot
target - target operator
input - target slot
See Also:
IAlgorithm.connect(org.evolvica.engine.IOperator, int, org.evolvica.engine.IOperator, int)

connect

public void connect(IElement source,
                    int output,
                    IElement target,
                    int input)
Description copied from interface: IAlgorithm
Connects two elements.

Specified by:
connect in interface IAlgorithm
Parameters:
source - source element
output - source slot
target - target element
input - target slot
See Also:
IAlgorithm.connect(org.evolvica.engine.IElement, int, org.evolvica.engine.IElement, int)

getConnection

public IConnection getConnection(IElement source,
                                 int output,
                                 IElement target,
                                 int input)
Description copied from interface: IAlgorithm
Returns the connection between two elements.

Specified by:
getConnection in interface IAlgorithm
Parameters:
source - source element
output - source slot
target - target element
input - target slot
Returns:
connection between the given elements or null if no such connection exists
See Also:
IAlgorithm.getConnection(org.evolvica.engine.IElement, int, org.evolvica.engine.IElement, int)

getConnection

public IConnection getConnection(IOperator source,
                                 int output,
                                 IOperator target,
                                 int input)
Description copied from interface: IAlgorithm
Returns the connection between two operators.

Specified by:
getConnection in interface IAlgorithm
Parameters:
source - source operator
output - source slot
target - target operator
input - target slot
Returns:
connection between the given operators or null if no such connection exists
See Also:
IAlgorithm.getConnection(org.evolvica.engine.IOperator, int, org.evolvica.engine.IOperator, int)

iterateConnections

public java.util.Iterator iterateConnections()
Description copied from interface: IAlgorithm
Iterates all connections in this algorithm.

Specified by:
iterateConnections in interface IAlgorithm
Returns:
iterator over all connections
See Also:
IAlgorithm.iterateConnections()

removeConnection

public void removeConnection(IConnection connection)
Description copied from interface: IAlgorithm
Removes a connection from this algorithm.

Specified by:
removeConnection in interface IAlgorithm
Parameters:
connection - connection to be removed.
See Also:
IAlgorithm.removeConnection(org.evolvica.engine.IConnection)

connectionSize

public int connectionSize()
Description copied from interface: IAlgorithm
Returns the number of connections in this algorithm.

Specified by:
connectionSize in interface IAlgorithm
Returns:
number of connections
See Also:
IAlgorithm.connectionSize()

setup

public abstract void setup()
                    throws java.lang.Exception
Description copied from interface: IAlgorithm
Sets up the algorithm. This method is called before the algorithm is started.

Specified by:
setup in interface IAlgorithm
Throws:
java.lang.Exception - thrown if the setup stage fails
See Also:
IAlgorithm.setup()

teardown

public abstract void teardown()
                       throws java.lang.Exception
Description copied from interface: IAlgorithm
Teardown method. This method is called after an algorithm has finished its execution.

Specified by:
teardown in interface IAlgorithm
Throws:
java.lang.Exception - thrown if teardown stage fails
See Also:
IAlgorithm.teardown()

execute

public void execute()
Description copied from interface: IAlgorithm
Executes the algorithm.

Specified by:
execute in interface IAlgorithm
See Also:
IAlgorithm.execute()

getName

public java.lang.String getName()
Description copied from interface: IAlgorithm
Returns the name of the algorithm.

Specified by:
getName in interface IAlgorithm
Returns:
name of the algorithm
See Also:
IAlgorithm.getName()

getRunner

public IRunner getRunner()
Description copied from interface: IAlgorithm
Gets the algorithm runner.

Specified by:
getRunner in interface IAlgorithm
Returns:
algorithm runner
See Also:
IAlgorithm.getRunner()

getValidator

public IValidator getValidator()
Description copied from interface: IAlgorithm
Gets the algorithm validator.

Specified by:
getValidator in interface IAlgorithm
Returns:
the current validator.
See Also:
IAlgorithm.getValidator()

setName

public void setName(java.lang.String string)
Description copied from interface: IAlgorithm
Sets the name of the algorithm.

Specified by:
setName in interface IAlgorithm
Parameters:
string - name of the algorithm
See Also:
IAlgorithm.setName(java.lang.String)

setRunner

public void setRunner(IRunner runner)
               throws java.beans.PropertyVetoException
Description copied from interface: IAlgorithm
Sets a new algorithm runner.

Specified by:
setRunner in interface IAlgorithm
Parameters:
runner - new algorithm runner
Throws:
java.beans.PropertyVetoException - thrown if algorithm runner is null
See Also:
IAlgorithm.setRunner(org.evolvica.engine.IRunner)

setValidator

public void setValidator(IValidator validator)
Description copied from interface: IAlgorithm
Sets the algorithm validator.

Specified by:
setValidator in interface IAlgorithm
Parameters:
validator - new algorithm validator
See Also:
IAlgorithm.setValidator(org.evolvica.engine.IValidator)

getMetadata

public Metadata getMetadata(java.lang.Object source,
                            java.lang.String path)
Description copied from interface: IAlgorithm
Returns a metadata object from the associated metadata store.

Specified by:
getMetadata in interface IAlgorithm
Parameters:
source - source object
path - metadata path
Returns:
metadata object or null if no such object exists
See Also:
IAlgorithm.getMetadata(java.lang.Object, java.lang.String)

restoreMetadata

public void restoreMetadata(IMetadataProvider provider)
Description copied from interface: IAlgorithm
Restores the metadata from the given metadata provider.

Specified by:
restoreMetadata in interface IAlgorithm
Parameters:
provider - metadata provider
See Also:
IAlgorithm.restoreMetadata(org.evolvica.util.IMetadataProvider)

serializeMetadata

public void serializeMetadata(IMetadataSerializer serializer)
Description copied from interface: IAlgorithm
Serializes this algorithm's metadata by using the given serializer.

Specified by:
serializeMetadata in interface IAlgorithm
Parameters:
serializer - metadata serializer
See Also:
IAlgorithm.serializeMetadata(org.evolvica.util.IMetadataSerializer)

setMetadata

public void setMetadata(java.lang.Object source,
                        Metadata data)
Description copied from interface: IAlgorithm
Sets a metadata object.

Specified by:
setMetadata in interface IAlgorithm
Parameters:
source - source object
data - metadata object
See Also:
IAlgorithm.setMetadata(java.lang.Object, org.evolvica.util.Metadata)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: IAlgorithm
Adds a property change listener to this algorithm.

Specified by:
addPropertyChangeListener in interface IAlgorithm
Parameters:
listener - property change listener to be added
See Also:
IAlgorithm.addPropertyChangeListener(java.beans.PropertyChangeListener)

addMetadataChangeListener

public void addMetadataChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: IAlgorithm
Adds a property change listener that reacts on metadata changes to this algorithm.

Specified by:
addMetadataChangeListener in interface IAlgorithm
Parameters:
listener - property change listener to be added
See Also:
IAlgorithm.addMetadataChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: IAlgorithm
Removes a property change listener from this algorithm.

Specified by:
removePropertyChangeListener in interface IAlgorithm
Parameters:
listener - property change listener to be removed
See Also:
IAlgorithm.removePropertyChangeListener(java.beans.PropertyChangeListener)

removeMetadataChangeListener

public void removeMetadataChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: IAlgorithm
Removes a metadata property change listener from this algorithm.

Specified by:
removeMetadataChangeListener in interface IAlgorithm
Parameters:
listener - property change listener to be removed
See Also:
IAlgorithm.removeMetadataChangeListener(java.beans.PropertyChangeListener)

firePropertyChangeEvent

public void firePropertyChangeEvent(java.beans.PropertyChangeEvent event)
Description copied from interface: IAlgorithm
Fires a property change event.

Specified by:
firePropertyChangeEvent in interface IAlgorithm
Parameters:
event - event to be fired
See Also:
IAlgorithm.firePropertyChangeEvent(java.beans.PropertyChangeEvent)

Evolvica Core API Version 0.6.2
Last Modified: June 29 2004

Copyright © 2000-2004 Technical University of Ilmenau, Department Electronic Circuits and Systems