rafa.math.gen
Class DiscontinuousFunctionStrategy

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

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

This engine returns values taken from a list of fragments taken from number generators, in an ordered way.
The length of the last fragment does not limit the ability to generate more values, as the last generator will be used to that end.
Objects of this class can detect changes in the provider generators.

Author:
rafa

Constructor Summary
DiscontinuousFunctionStrategy()
           
 
Method Summary
 DiscontinuousFunctionStrategy addFragment(java.lang.Integer index, NumberGeneratorFragment fragment)
          Adds a series of values from other generator to the list.
protected  GeneratorDependency buildDependency(NumberGeneratorFragment fragment, int i)
          Builds a dependency on a generator fragment.
 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.
 java.util.List<NumberGeneratorFragment> getFragments()
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 NumberGeneratorFragment removeFragment(int n)
          Removes a fragment.
 boolean removeFragment(NumberGeneratorFragment fragment)
          Removes a fragment.
 void reset()
          Resets the strategy to its initial state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiscontinuousFunctionStrategy

public DiscontinuousFunctionStrategy()
Method Detail

addFragment

public DiscontinuousFunctionStrategy addFragment(java.lang.Integer index,
                                                 NumberGeneratorFragment fragment)
Adds a series of values from other generator to the list.

Parameters:
index - TODO
fragment - the section of values to add from a generator
Returns:
this DiscontinuousFunctionStrategy object (allows chaining calls to this method).

buildDependency

protected GeneratorDependency buildDependency(NumberGeneratorFragment fragment,
                                              int i)
Builds a dependency on a generator fragment.

Parameters:
fragment - the generator fragment.
i - the index of the first dependent value.
Returns:
a GeneratorDependency on the generator providing the fragment.

removeFragment

public boolean removeFragment(NumberGeneratorFragment fragment)
Removes a fragment. This object is removed from the list of listeners of the provider generator.

Parameters:
fragment - the fragment to remove
Returns:
true if it was successfuly removed, false otherwise.

removeFragment

public NumberGeneratorFragment removeFragment(int n)
Removes a fragment. This object is removed from the list of listeners of the provider generator.

Parameters:
n - the index of the fragment to remove.
Returns:
the removed fragment.

getFragments

public java.util.List<NumberGeneratorFragment> getFragments()
Returns:

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()
Description copied from interface: GeneratorStrategy
Resets the strategy to its initial state.

Specified by:
reset in interface GeneratorStrategy

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
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.