org.progeeks.tool.gen
Class ComplexObjectGenerator

java.lang.Object
  extended by org.progeeks.tool.gen.BaseDataGenerator
      extended by org.progeeks.tool.gen.ComplexObjectGenerator
All Implemented Interfaces:
DataGenerator

public class ComplexObjectGenerator
extends BaseDataGenerator

Constructs an object by iterating over a collection of sub-generators to get the values for each of the object's properties. A single sub-generator may be used to set more than one property. If a property is not assigned a sub-generator, it is not explicitely set by the generator (though it may still contain a value if set indirectly by some other call).

Version:
$Revision: 1.10 $
Author:
esword

Field Summary
protected  ComplexObjectGenerator baseClassGenerator
           
protected  boolean dataClassIsMetaClass
           
protected static Log log
           
protected static MetaKit metaKit
           
protected  java.util.Map propGenerators
           
 
Fields inherited from class org.progeeks.tool.gen.BaseDataGenerator
allowNull, nullPercentage
 
Constructor Summary
ComplexObjectGenerator()
           
 
Method Summary
protected  java.lang.Object generateRealData(DataGeneratorContext context)
          Creates an object of the proper type with properties set as specified by the property generators.
protected  java.lang.Object generateRealData(java.lang.Object dataObject, DataGeneratorContext context)
          Populates the given object with properties set as specified by the property generators.
 ComplexObjectGenerator getBaseClassGenerator()
           
 java.util.Map getPropGenerators()
           
protected  void init()
          Validates input settings
 void setBaseClassGenerator(ComplexObjectGenerator superClassGenerator)
          Generator that can be used to set fields prior to any generators in the propGenerators map.
 void setDataClass(java.lang.String dataClass)
          The full java class name or a MetaClass name of the objects to create
 void setPropGenerators(java.util.Map generators)
          Map where the keys are property names and the data is a generator for that property.
protected  boolean testData(java.lang.Object testItem, DataGeneratorContext context)
          Left for sub-classes.
 java.lang.String toString()
           
 
Methods inherited from class org.progeeks.tool.gen.BaseDataGenerator
generateData, getAllowNull, getDataClass, getDataClazz, getEnforceResolvable, getNullPercentage, isDataValid, setAllowNull, setEnforceResolvable, setNullPercentage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final Log log

baseClassGenerator

protected ComplexObjectGenerator baseClassGenerator

propGenerators

protected java.util.Map propGenerators

metaKit

protected static MetaKit metaKit

dataClassIsMetaClass

protected boolean dataClassIsMetaClass
Constructor Detail

ComplexObjectGenerator

public ComplexObjectGenerator()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

init

protected void init()
             throws java.lang.Exception
Validates input settings

Throws:
java.lang.Exception

generateRealData

protected java.lang.Object generateRealData(DataGeneratorContext context)
Creates an object of the proper type with properties set as specified by the property generators.

Specified by:
generateRealData in class BaseDataGenerator

generateRealData

protected java.lang.Object generateRealData(java.lang.Object dataObject,
                                            DataGeneratorContext context)
Populates the given object with properties set as specified by the property generators.


testData

protected boolean testData(java.lang.Object testItem,
                           DataGeneratorContext context)
Description copied from class: BaseDataGenerator
Left for sub-classes. Subclasses do not have to check for null.

Specified by:
testData in class BaseDataGenerator

getPropGenerators

public java.util.Map getPropGenerators()
Returns:
Returns the generators used to set the properties.

setPropGenerators

public void setPropGenerators(java.util.Map generators)
Map where the keys are property names and the data is a generator for that property. The order in which properties are set can be enforced by using a LinkedHashMap. This is most useful if there are ConditionalDataGenerators that depend on the value of another property or another object entirely.

Parameters:
generators - The generators to set.

getBaseClassGenerator

public ComplexObjectGenerator getBaseClassGenerator()
Returns:
Returns the baseClassGenerator.

setBaseClassGenerator

public void setBaseClassGenerator(ComplexObjectGenerator superClassGenerator)
Generator that can be used to set fields prior to any generators in the propGenerators map. Useful for creating generators for a set of classes that extend a common base class.

Parameters:
baseClassGenerator - The baseClassGenerator to set.

setDataClass

public void setDataClass(java.lang.String dataClass)
Description copied from class: BaseDataGenerator
The full java class name or a MetaClass name of the objects to create

Specified by:
setDataClass in interface DataGenerator
Overrides:
setDataClass in class BaseDataGenerator
Parameters:
dataClass - The dataClass to set.


Copyright © 2002-2003 Paul Speed. All Rights Reserved.