org.databene.benerator.wrapper
Class MultiGeneratorWrapper<S,P>

java.lang.Object
  extended by org.databene.benerator.util.AbstractGenerator<P>
      extended by org.databene.benerator.wrapper.MultiGeneratorWrapper<S,P>
All Implemented Interfaces:
java.io.Closeable, Generator<P>, org.databene.commons.Resettable, org.databene.commons.ThreadAware
Direct Known Subclasses:
AlternativeGenerator, GeneratorChain, SimpleMultiSourceArrayGenerator, UniqueMultiSourceArrayGenerator, UniqueScrambledStringGenerator, WeightedGeneratorGenerator

public abstract class MultiGeneratorWrapper<S,P>
extends AbstractGenerator<P>

Parent class for wrapping several other generators (in a sources property) and refining a composite state from them.

Created: 19.12.2006 07:05:29

Since:
0.1
Author:
Volker Bergmann

Field Summary
protected  java.lang.Class<P> generatedType
           
protected  java.util.List<Generator<? extends S>> sources
           
 
Fields inherited from class org.databene.benerator.util.AbstractGenerator
context, logger, state
 
Constructor Summary
MultiGeneratorWrapper(java.lang.Class<P> generatedType, Generator<? extends S>... sources)
           
MultiGeneratorWrapper(java.lang.Class<P> generatedType, java.util.List<Generator<? extends S>> sources)
           
 
Method Summary
 void addSource(Generator<? extends S> source)
           
protected  int availableSourceCount()
           
 void close()
          Closes the generator.
protected  S[] generateFromAllSources(java.lang.Class<S> componentType)
           
protected  ProductWrapper<S> generateFromAvailableSource(int i, ProductWrapper<S> wrapper)
           
protected  ProductWrapper<S> generateFromRandomSource(ProductWrapper<S> wrapper)
           
protected  ProductWrapper<java.lang.String> generateFromSource(int index, ProductWrapper<S> wrapper)
           
protected  Generator<? extends S> getAvailableSource(int index)
           
 java.lang.Class<P> getGeneratedType()
          Declares the type of the objects returned by the generate() method.
 Generator<? extends S> getSource(int index)
           
 java.util.List<Generator<? extends S>> getSources()
           
protected  ProductWrapper<S> getSourceWrapper()
           
 void init(GeneratorContext context)
           
 boolean isParallelizable()
           
 boolean isThreadSafe()
           
 void reset()
           
 void setSources(java.util.List<Generator<? extends S>> sources)
           
 java.lang.String toString()
           
 
Methods inherited from class org.databene.benerator.util.AbstractGenerator
assertInitialized, assertNotInitialized, getResultWrapper, wasInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.databene.benerator.Generator
generate
 

Field Detail

generatedType

protected java.lang.Class<P> generatedType

sources

protected java.util.List<Generator<? extends S>> sources
Constructor Detail

MultiGeneratorWrapper

public MultiGeneratorWrapper(java.lang.Class<P> generatedType,
                             Generator<? extends S>... sources)

MultiGeneratorWrapper

public MultiGeneratorWrapper(java.lang.Class<P> generatedType,
                             java.util.List<Generator<? extends S>> sources)
Method Detail

getSources

public java.util.List<Generator<? extends S>> getSources()

setSources

public void setSources(java.util.List<Generator<? extends S>> sources)

getSource

public Generator<? extends S> getSource(int index)

addSource

public void addSource(Generator<? extends S> source)

availableSourceCount

protected int availableSourceCount()

getAvailableSource

protected Generator<? extends S> getAvailableSource(int index)

getGeneratedType

public java.lang.Class<P> getGeneratedType()
Description copied from interface: Generator
Declares the type of the objects returned by the generate() method.


init

public void init(GeneratorContext context)
Specified by:
init in interface Generator<P>
Overrides:
init in class AbstractGenerator<P>

reset

public void reset()
Specified by:
reset in interface org.databene.commons.Resettable
Overrides:
reset in class AbstractGenerator<P>

close

public void close()
Description copied from interface: Generator
Closes the generator. After invocation the state is unavailable.

Specified by:
close in interface java.io.Closeable
Specified by:
close in interface Generator<P>
Overrides:
close in class AbstractGenerator<P>

isThreadSafe

public boolean isThreadSafe()

isParallelizable

public boolean isParallelizable()

getSourceWrapper

protected ProductWrapper<S> getSourceWrapper()

generateFromRandomSource

protected ProductWrapper<S> generateFromRandomSource(ProductWrapper<S> wrapper)

generateFromSource

protected ProductWrapper<java.lang.String> generateFromSource(int index,
                                                              ProductWrapper<S> wrapper)

generateFromAvailableSource

protected ProductWrapper<S> generateFromAvailableSource(int i,
                                                        ProductWrapper<S> wrapper)

generateFromAllSources

protected S[] generateFromAllSources(java.lang.Class<S> componentType)

toString

public java.lang.String toString()
Overrides:
toString in class AbstractGenerator<P>


Copyright © 2013. All Rights Reserved.