org.databene.benerator.wrapper
Class ConvertingGenerator<S,T>

java.lang.Object
  extended by org.databene.benerator.util.AbstractGenerator<P>
      extended by org.databene.benerator.wrapper.GeneratorWrapper<S,T>
          extended by org.databene.benerator.wrapper.ConvertingGenerator<S,T>
All Implemented Interfaces:
java.io.Closeable, Generator<T>, org.databene.commons.Resettable, org.databene.commons.ThreadAware
Direct Known Subclasses:
AsStringGenerator

public class ConvertingGenerator<S,T>
extends GeneratorWrapper<S,T>

Reads products from a source Generator and applies a Converter to transform them into the target products.

Created: 12.06.2006 19:02:30

Since:
0.1
Author:
Volker Bergmann

Field Summary
protected  org.databene.commons.Converter<?,?>[] converters
          The converter to apply to the source's products
 
Fields inherited from class org.databene.benerator.util.AbstractGenerator
context, logger, state
 
Constructor Summary
ConvertingGenerator(Generator<S> source, org.databene.commons.Converter<?,?>... converters)
          Initializes all attributes
 
Method Summary
 ProductWrapper<T> generate(ProductWrapper<T> wrapper)
          Returns an instance of the generic type E, using the ProductWrapper instance provided as argument.
 java.lang.Class<T> getGeneratedType()
          Declares the type of the objects returned by the generate() method.
 void init(GeneratorContext context)
           
 java.lang.String toString()
           
 
Methods inherited from class org.databene.benerator.wrapper.GeneratorWrapper
close, equals, generateFromSource, getSource, getSourceWrapper, hashCode, isParallelizable, isThreadSafe, reset, setSource
 
Methods inherited from class org.databene.benerator.util.AbstractGenerator
assertInitialized, assertNotInitialized, getResultWrapper, wasInitialized
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

converters

protected org.databene.commons.Converter<?,?>[] converters
The converter to apply to the source's products

Constructor Detail

ConvertingGenerator

public ConvertingGenerator(Generator<S> source,
                           org.databene.commons.Converter<?,?>... converters)
Initializes all attributes

Method Detail

init

public void init(GeneratorContext context)
Specified by:
init in interface Generator<T>
Overrides:
init in class GeneratorWrapper<S,T>

getGeneratedType

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


generate

public ProductWrapper<T> generate(ProductWrapper<T> wrapper)
Description copied from interface: Generator
Returns an instance of the generic type E, using the ProductWrapper instance provided as argument. The wrapper may wrap a null value as a regular generator product. If the generator is not available (any more), it returns null instead of the ProductWrapper instance.


toString

public java.lang.String toString()
Overrides:
toString in class GeneratorWrapper<S,T>


Copyright © 2013. All Rights Reserved.