rafa.math.gen
Class NumberGenerator

java.lang.Object
  extended by rafa.NamedListened
      extended by rafa.math.gen.NumberGenerator
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, Dependent, Listened, INumberGenerator, Named

public class NumberGenerator
extends NamedListened
implements INumberGenerator

Generates values according to the implemented logic.

Author:
rafa

Nested Class Summary
 
Nested classes/interfaces inherited from class rafa.NamedListened
NamedListened.Property
 
Nested classes/interfaces inherited from interface rafa.math.gen.INumberGenerator
INumberGenerator.Property
 
Field Summary
protected  java.util.List<java.lang.Number> values
          List of generated values.
 
Fields inherited from class rafa.NamedListened
name, propertyChangeSupport
 
Constructor Summary
NumberGenerator(java.lang.String name, GeneratorStrategy strategy)
           
 
Method Summary
 void generate()
          Performs an iteration of value generation.
 java.util.Collection<Dependency> getDependencies(java.lang.Object dep)
          Gets detailed information about the dependencies of this object on a given one.
 GeneratorStrategy getStrategy()
           
 java.lang.Number getValue(int index)
           
 java.util.List<java.lang.Number> getValues()
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void reset()
          Resets the generator to initial values.
 void setStrategy(GeneratorStrategy strategy)
           
 
Methods inherited from class rafa.NamedListened
addListener, getName, removeListener, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface rafa.Named
getName, setName
 
Methods inherited from interface rafa.Listened
addListener, removeListener
 

Field Detail

values

protected java.util.List<java.lang.Number> values
List of generated values.

Constructor Detail

NumberGenerator

public NumberGenerator(java.lang.String name,
                       GeneratorStrategy strategy)
                throws CircularDependencyException
Throws:
CircularDependencyException
Method Detail

generate

public void generate()
              throws java.lang.Exception
Description copied from interface: INumberGenerator
Performs an iteration of value generation.

Specified by:
generate in interface INumberGenerator
Throws:
java.lang.Exception

getValue

public java.lang.Number getValue(int index)
                          throws java.lang.Exception
Specified by:
getValue in interface INumberGenerator
Parameters:
index - The value index. If negative, begin at the end.
Returns:
The value. If index doesn't exist, values are generated until it does.
Throws:
java.lang.Exception

getValues

public java.util.List<java.lang.Number> getValues()
Specified by:
getValues in interface INumberGenerator
Returns:
Returns the values.

getStrategy

public GeneratorStrategy getStrategy()
Returns:

setStrategy

public void setStrategy(GeneratorStrategy strategy)
                 throws CircularDependencyException
Parameters:
strategy -
Throws:
CircularDependencyException

reset

public void reset()
Description copied from interface: INumberGenerator
Resets the generator to initial values.

Specified by:
reset in interface INumberGenerator

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.