org.databene.benerator.wrapper
Class MessageGenerator

java.lang.Object
  extended by org.databene.benerator.util.AbstractGenerator<P>
      extended by org.databene.benerator.util.ValidatingGenerator<java.lang.String>
          extended by org.databene.benerator.wrapper.MessageGenerator
All Implemented Interfaces:
java.io.Closeable, Generator<java.lang.String>, NonNullGenerator<java.lang.String>, org.databene.commons.Resettable, org.databene.commons.ThreadAware

public class MessageGenerator
extends ValidatingGenerator<java.lang.String>
implements NonNullGenerator<java.lang.String>

Assembles the output of several source generators by a java.text.MessageFormat.

Created: 08.06.2006 21:48:08

Since:
0.1
Author:
Volker Bergmann

Field Summary
 
Fields inherited from class org.databene.benerator.util.ValidatingGenerator
ERROR_THRESHOLD, validator, WARNING_THRESHOLD
 
Fields inherited from class org.databene.benerator.util.AbstractGenerator
context, state
 
Constructor Summary
MessageGenerator()
          Sets minLength to 0, maxLength to 30 and all other values empty.
MessageGenerator(java.lang.String pattern, Generator<?>... sources)
           
MessageGenerator(java.lang.String pattern, int minLength, int maxLength, Generator<?>... sources)
          Initializes Generator
 
Method Summary
 void close()
          Closes the generator.
protected  ProductWrapper<java.lang.String> doGenerate(ProductWrapper<java.lang.String> wrapper)
          Implementation of ValidatingGenerator's generation callback method
 java.lang.String generate()
           
 java.lang.Class<java.lang.String> getGeneratedType()
          Declares the type of the objects returned by the generate() method.
 int getMaxLength()
           
 int getMinLength()
           
 java.lang.String getPattern()
          Returns the pattern property
 void init(GeneratorContext context)
          ensures consistency of the generator's state
 boolean isParallelizable()
           
 boolean isThreadSafe()
           
 void reset()
           
 void setMaxLength(int maxLength)
           
 void setMinLength(int minLength)
           
 void setPattern(java.lang.String pattern)
          Sets the pattern property
 void setSources(Generator<?>[] sources)
          Sets the source generators
 java.lang.String toString()
          Returns a String representation of the generator
 
Methods inherited from class org.databene.benerator.util.ValidatingGenerator
generate
 
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, wasInitialized
 

Constructor Detail

MessageGenerator

public MessageGenerator()
Sets minLength to 0, maxLength to 30 and all other values empty.


MessageGenerator

public MessageGenerator(java.lang.String pattern,
                        Generator<?>... sources)

MessageGenerator

public MessageGenerator(java.lang.String pattern,
                        int minLength,
                        int maxLength,
                        Generator<?>... sources)
Initializes Generator

Method Detail

getPattern

public java.lang.String getPattern()
Returns the pattern property


setPattern

public void setPattern(java.lang.String pattern)
Sets the pattern property


getMinLength

public int getMinLength()

setMinLength

public void setMinLength(int minLength)

getMaxLength

public int getMaxLength()

setMaxLength

public void setMaxLength(int maxLength)

setSources

public void setSources(Generator<?>[] sources)
Sets the source generators


init

public void init(GeneratorContext context)
ensures consistency of the generator's state

Specified by:
init in interface Generator<java.lang.String>
Overrides:
init in class AbstractGenerator<java.lang.String>

getGeneratedType

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

Specified by:
getGeneratedType in interface Generator<java.lang.String>

generate

public java.lang.String generate()
Specified by:
generate in interface NonNullGenerator<java.lang.String>

doGenerate

protected ProductWrapper<java.lang.String> doGenerate(ProductWrapper<java.lang.String> wrapper)
Implementation of ValidatingGenerator's generation callback method

Specified by:
doGenerate in class ValidatingGenerator<java.lang.String>

reset

public void reset()
Specified by:
reset in interface org.databene.commons.Resettable
Overrides:
reset in class AbstractGenerator<java.lang.String>
See Also:
Resettable.reset()

isParallelizable

public boolean isParallelizable()
Specified by:
isParallelizable in interface org.databene.commons.ThreadAware

isThreadSafe

public boolean isThreadSafe()
Specified by:
isThreadSafe in interface org.databene.commons.ThreadAware

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<java.lang.String>
Overrides:
close in class AbstractGenerator<java.lang.String>
See Also:
Generator.close()

toString

public java.lang.String toString()
Returns a String representation of the generator

Overrides:
toString in class AbstractGenerator<java.lang.String>


Copyright © 2013. All Rights Reserved.