tenua.simulator
Class AbstractDataGenerator

java.lang.Object
  extended by tenua.simulator.AbstractDataGenerator
All Implemented Interfaces:
java.lang.Runnable, DataGenerator
Direct Known Subclasses:
Mechanism, StringDataGenerator

public class AbstractDataGenerator
extends java.lang.Object
implements DataGenerator

Author:
Daniel Wachsstock

Nested Class Summary
 
Nested classes/interfaces inherited from interface tenua.simulator.DataGenerator
DataGenerator.Listener
 
Constructor Summary
AbstractDataGenerator()
          Creates a new instance of AbstractDataGenerator with one output
AbstractDataGenerator(int n)
          Creates a new instance of AbstractDataGenerator
AbstractDataGenerator(java.util.List names)
          Creates a new instance of AbstractDataGenerator
 
Method Summary
 void addListener(DataGenerator.Listener listener)
          add a DataGenerator.Listener to this DataGenerator's list
 java.lang.Object getMemento()
          returns a memento for this DataGenerator.
 java.util.List getNames()
           
 void removeListener(DataGenerator.Listener listener)
          remove a given DataGenerator.Listener from this DataGenerator's list
 void run()
          run the data generator, in a form suitable for putting in a Thread
 void start(java.lang.Object memento)
          restart a generation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDataGenerator

public AbstractDataGenerator()
Creates a new instance of AbstractDataGenerator with one output


AbstractDataGenerator

public AbstractDataGenerator(int n)
Creates a new instance of AbstractDataGenerator

Parameters:
n - the number of outputs

AbstractDataGenerator

public AbstractDataGenerator(java.util.List names)
Creates a new instance of AbstractDataGenerator

Parameters:
names - the names of the outputs
Method Detail

start

public void start(java.lang.Object memento)
restart a generation. Calls each listener with DataGenerator.Listener.startingUp().

Specified by:
start in interface DataGenerator
Parameters:
memento - a Memento of the internal state of the data generator, or null to start afresh. Calls startingUp on each listener either way

a Memento returned by DataGenerator.getMemento() for the same DataGenerator is guarranteed not to throw and will continue the data generation from "close" to where it was generated. "close" is implementation-specific

Throws:
java.lang.UnsupportedOperationException - if memento != null

getMemento

public java.lang.Object getMemento()
returns a memento for this DataGenerator. Not supported.

Specified by:
getMemento in interface DataGenerator
Returns:
the current internal state; what this means is implementation specific. It also does not guarrantee that the data generator can be started up in exactly the same state it is in now, just that it will be "close" in some sense and it would be possible to reset it to that Memento with DataGenerator.start(Object)
Throws:
java.lang.UnsupportedOperationException

getNames

public java.util.List getNames()
Specified by:
getNames in interface DataGenerator
Returns:
the names of the output data. If there are no names, it will be an list of empty strings (not null!), which will at least give the caller the number of outputs

addListener

public void addListener(DataGenerator.Listener listener)
Description copied from interface: DataGenerator
add a DataGenerator.Listener to this DataGenerator's list

Specified by:
addListener in interface DataGenerator

removeListener

public void removeListener(DataGenerator.Listener listener)
Description copied from interface: DataGenerator
remove a given DataGenerator.Listener from this DataGenerator's list

Specified by:
removeListener in interface DataGenerator

run

public void run()
run the data generator, in a form suitable for putting in a Thread

Specified by:
run in interface java.lang.Runnable