public abstract class DataGenerator
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected org.licas_xml.abs.Element |
adminXml
An admin document might have been passed through the constructor
|
protected java.lang.String |
dataType
The data type
|
protected java.lang.String |
maxValue
The maximum allowed value
|
protected java.lang.String |
minValue
The minimum allowed value
|
protected java.util.Random |
rnd
The random number generator
|
protected long |
seed
A seed value that can be used to initialise a random number generator
|
| Constructor and Description |
|---|
DataGenerator(org.licas_xml.abs.Element adminXml)
Create a new instance of DataGenerator.
|
DataGenerator(long thisSeed,
java.lang.String thisDataType)
Create a new instance of DataGenerator, ignoring the base service features.
|
| Modifier and Type | Method and Description |
|---|---|
static org.licas_xml.abs.Element |
conditionsToXml(BehaviourScript testScript,
long rndSeed)
Create an XML script that can be used to initialise an instance of the
derived class.
|
static org.licas_xml.abs.Element |
conditionsToXml(int index,
BehaviourScript testScript,
long rndSeed)
Create an XML script that can be used to initialise an instance of the
derived class.
|
static org.licas_xml.abs.Element |
conditionsToXml(java.lang.String dataType,
double minValue,
double maxValue,
java.lang.String dataCondition,
long rndSeed)
Create an XML script that can be used to initialise an instance of the
derived class.
|
static java.lang.String |
generateStringRange(int stringLength)
Generate the new data range.
|
protected org.licas_xml.abs.Element |
getBaseElement(org.licas_xml.abs.Element adminXml)
Get the base data generator element from the admin document element.
|
java.lang.String |
getDataType()
Get the data type created by this generator.
|
static java.lang.String |
getGeneratorClass(java.lang.String dataType)
Get the generator class for the specified data type.
|
abstract java.lang.Object |
getNextValue()
Generate the next data value.
|
static boolean |
isAllowedDataType(java.lang.String generator,
java.lang.String theDataType)
This method creates a data generator of the specified type and checks if
the data type entered is allowed.
|
abstract void |
parseGenXml(org.licas_xml.abs.Element genXml)
Parse the data generator script to set the appropriate variable values.
|
void |
setMaxValue(java.lang.String thisValue)
Set the maximum value for data generation.
|
void |
setMinValue(java.lang.String thisValue)
Set the minimum value for data generation.
|
protected java.lang.String dataType
protected long seed
protected java.lang.String minValue
protected java.lang.String maxValue
protected org.licas_xml.abs.Element adminXml
protected java.util.Random rnd
public DataGenerator(long thisSeed,
java.lang.String thisDataType)
thisDataType - the generator data type.thisSeed - to seed a random number generator. Can be 0 if not used.public DataGenerator(org.licas_xml.abs.Element adminXml)
throws java.lang.Exception
adminXml - a script including the value ranges for the data. This
would now be a full admin script, with an Const.PARAMETERS
section for these values.java.lang.Exception - any error.public abstract void parseGenXml(org.licas_xml.abs.Element genXml)
throws java.lang.Exception
genXml - the script to parsejava.lang.Exception - any error.public abstract java.lang.Object getNextValue()
throws java.lang.Exception
java.lang.Exception - any error.protected org.licas_xml.abs.Element getBaseElement(org.licas_xml.abs.Element adminXml)
adminXml - the constructor document. Should contain other child elements.public void setMinValue(java.lang.String thisValue)
thisValue - the minimum value. This needs to then be converted
to the actual value type.public void setMaxValue(java.lang.String thisValue)
thisValue - the maximum value. This needs to then be converted
to the actual value type.public java.lang.String getDataType()
public static boolean isAllowedDataType(java.lang.String generator,
java.lang.String theDataType)
generator - the generator class name.theDataType - the data type class name.public static java.lang.String getGeneratorClass(java.lang.String dataType)
dataType - the data type class name.ObjectDataGenerator class is returned if there is no match.public static org.licas_xml.abs.Element conditionsToXml(BehaviourScript testScript, long rndSeed)
testScript - the test script with the config information.rndSeed - a seed for a random number generator if required. Can be 0.public static org.licas_xml.abs.Element conditionsToXml(int index,
BehaviourScript testScript,
long rndSeed)
index - a data index can be included for retrieving a string-based data
condition from the script, specifically, a testScript.dataConditions element.testScript - the test script with the config information.rndSeed - a seed for a random number generator if required. Can be 0.public static org.licas_xml.abs.Element conditionsToXml(java.lang.String dataType,
double minValue,
double maxValue,
java.lang.String dataCondition,
long rndSeed)
dataType - the data type class name.minValue - minimum value for the data generator.maxValue - maximum value for the data generator.dataCondition - condition under which data can be generated. Can be null
or empty for a default setting.rndSeed - a seed for a random number generator if required. Can be 0.public static java.lang.String generateStringRange(int stringLength)
stringLength - the length of the string to generate.