org.databene.benerator.util
Class ValidatingGenerator<P>

java.lang.Object
  extended by org.databene.benerator.util.AbstractGenerator<P>
      extended by org.databene.benerator.util.ValidatingGenerator<P>
All Implemented Interfaces:
java.io.Closeable, Generator<P>, org.databene.commons.Resettable, org.databene.commons.ThreadAware
Direct Known Subclasses:
MessageGenerator, ValidatingGeneratorProxy

public abstract class ValidatingGenerator<P>
extends AbstractGenerator<P>

Provides an abstract implementation of a generator that validates its generated values.

Created: 23.09.2006 00:03:04

Since:
0.1
Author:
Volker Bergmann

Field Summary
static int ERROR_THRESHOLD
          The number of invalid consecutive generations that causes an exception
protected  org.databene.commons.Validator<P> validator
          The validator used for validation
static int WARNING_THRESHOLD
          The number of invalid consecutive generations that causes a warning
 
Fields inherited from class org.databene.benerator.util.AbstractGenerator
context, state
 
Constructor Summary
ValidatingGenerator(org.databene.commons.Validator<P> validator)
          Constructor that takes the validator
 
Method Summary
protected abstract  ProductWrapper<P> doGenerate(ProductWrapper<P> wrapper)
          Callback method that does the job of creating values.
 ProductWrapper<P> generate(ProductWrapper<P> wrapper)
          Generator implementation that calls generateImpl() to generate values and validator.validate() in order to validate them.
 
Methods inherited from class org.databene.benerator.util.AbstractGenerator
assertInitialized, assertNotInitialized, close, getResultWrapper, init, reset, toString, 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
getGeneratedType
 
Methods inherited from interface org.databene.commons.ThreadAware
isParallelizable, isThreadSafe
 

Field Detail

WARNING_THRESHOLD

public static final int WARNING_THRESHOLD
The number of invalid consecutive generations that causes a warning

See Also:
Constant Field Values

ERROR_THRESHOLD

public static final int ERROR_THRESHOLD
The number of invalid consecutive generations that causes an exception

See Also:
Constant Field Values

validator

protected org.databene.commons.Validator<P> validator
The validator used for validation

Constructor Detail

ValidatingGenerator

public ValidatingGenerator(org.databene.commons.Validator<P> validator)
Constructor that takes the validator

Method Detail

generate

public ProductWrapper<P> generate(ProductWrapper<P> wrapper)
Generator implementation that calls generateImpl() to generate values and validator.validate() in order to validate them. Consecutive invalid values are counted. If this count reaches the WARNING_THRESHOLD value, a warning is logged, if the count reaches the ERROR_THRESHOLD, an exception is raised.


doGenerate

protected abstract ProductWrapper<P> doGenerate(ProductWrapper<P> wrapper)
Callback method that does the job of creating values. This is to be implemented by child classes.



Copyright © 2013. All Rights Reserved.