rafa.math.gen
Class SerialStrategy

java.lang.Object
  extended by rafa.math.gen.SerialStrategy
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, Dependent, GeneratorStrategy

public class SerialStrategy
extends java.lang.Object
implements GeneratorStrategy, java.beans.PropertyChangeListener, Dependent

Generates a series of values. The values returned come from the series, be it in an ordered, random or random without repeats way.

Author:
rafa

Nested Class Summary
static class SerialStrategy.Output
          Mechanism for choosing values from the series.
 
Field Summary
protected  java.util.List<java.lang.Number> noRepeatsSeries
          A copy of the series, from which values are withdrawn when the output is random without repeats.
protected  SerialStrategy.Output outputType
          Output type.
protected  java.util.List<java.lang.Number> series
          The series of candidate values for output by this generator.
 
Constructor Summary
SerialStrategy(java.util.List<? extends java.lang.Number> series)
          Constructor for a serial generator which will use a series passed as a parameter.
SerialStrategy(NumberGeneratorFragment providerGeneratorFragment)
          Constructor for a serial generator which will use a series taken from other generator's values.
 
Method Summary
protected  Dependency buildDependency()
          Builds a dependency on the underlying provider generator.
 java.util.List<? extends java.lang.Number> generate(int index)
          Generates new numbers.
 java.util.Collection<Dependency> getDependencies(java.lang.Object dep)
          Gets detailed information about the dependencies of this object on a given one.
 SerialStrategy.Output getOutputType()
           
 NumberGeneratorFragment getProviderFragment()
           
 java.util.List<java.lang.Number> getSeries()
           
 void propertyChange(java.beans.PropertyChangeEvent event)
          This strategy reacts to RESET events from the provider generator (if any), and the series is updated accordingly with new values.
 void reset()
          This method does not clear the series.
 void setOutputType(SerialStrategy.Output o)
           
 void setSeries(java.util.List<java.lang.Number> list)
           
 void setSeries(NumberGeneratorFragment ngf)
          Take the series of values from a number generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

series

protected java.util.List<java.lang.Number> series
The series of candidate values for output by this generator.


noRepeatsSeries

protected java.util.List<java.lang.Number> noRepeatsSeries
A copy of the series, from which values are withdrawn when the output is random without repeats.


outputType

protected SerialStrategy.Output outputType
Output type.

Constructor Detail

SerialStrategy

public SerialStrategy(java.util.List<? extends java.lang.Number> series)
               throws EmptySeriesException
Constructor for a serial generator which will use a series passed as a parameter.

Parameters:
series -
Throws:
EmptySeriesException

SerialStrategy

public SerialStrategy(NumberGeneratorFragment providerGeneratorFragment)
               throws java.lang.Exception
Constructor for a serial generator which will use a series taken from other generator's values.

Parameters:
providerGeneratorFragment -
Throws:
java.lang.Exception - if any problems during number generation.
Method Detail

generate

public java.util.List<? extends java.lang.Number> generate(int index)
                                                    throws java.lang.Exception
Description copied from interface: GeneratorStrategy
Generates new numbers.

Specified by:
generate in interface GeneratorStrategy
Parameters:
index - the index of the value within the strategy output. Note that it can be ignored by the implementation, if not needed.
Returns:
A list of numbers, or null if none was generated.
Throws:
java.lang.Exception

reset

public void reset()
This method does not clear the series.

Specified by:
reset in interface GeneratorStrategy

getOutputType

public SerialStrategy.Output getOutputType()
Returns:

getSeries

public java.util.List<java.lang.Number> getSeries()
Returns:

getProviderFragment

public NumberGeneratorFragment getProviderFragment()
Returns:

setOutputType

public void setOutputType(SerialStrategy.Output o)
Parameters:
o -

buildDependency

protected Dependency buildDependency()
Builds a dependency on the underlying provider generator.

Returns:
a dependency.

setSeries

public void setSeries(java.util.List<java.lang.Number> list)
               throws EmptySeriesException
Parameters:
list -
Throws:
EmptySeriesException

setSeries

public void setSeries(NumberGeneratorFragment ngf)
Take the series of values from a number generator.

Parameters:
ngf -
Throws:
java.lang.Exception

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
This strategy reacts to RESET events from the provider generator (if any), and the series is updated accordingly with new values.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

getDependencies

public java.util.Collection<Dependency> getDependencies(java.lang.Object dep)
Description copied from interface: Dependent
Gets detailed information about the dependencies of this object on a given one.

Specified by:
getDependencies in interface Dependent
Parameters:
dep - the required object. If null, all of the dependencies will be returned.
Returns:
a collection of Dependency objects pointing to the same object (target), or null if there is no dependency on that object.


Copyright © 2008-2009. All Rights Reserved.