Package ru.ispras.testbase.generator
Class DataGeneratorBase
- java.lang.Object
-
- ru.ispras.testbase.generator.DataGeneratorBase
-
- All Implemented Interfaces:
DataGenerator
public abstract class DataGeneratorBase extends java.lang.Object implements DataGenerator
TheDataGeneratorBase
class provides a basic implementation of a data generator.
-
-
Constructor Summary
Constructors Constructor Description DataGeneratorBase(java.lang.String name)
Constructs a data generator with the specified name applicable to all instructions.DataGeneratorBase(java.lang.String name, java.util.Set<java.lang.String> instructions)
Constructs a data generator with the specified name applicable to the specified instructions.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
generate(DataGeneratorQuery query)
Generates data for the specified data generator query.Iterator<TestData>
generate(TestBaseQuery query)
Generates data for the specified query.java.lang.String
getName()
Returns data generator name.boolean
isSuitable(TestBaseQuery query)
Checks whether the data generator is capable of generating data for the specified query.protected void
setValue(DataGeneratorVariable variable, int value)
Assigns an integer value to the specified variable.protected void
setValue(DataGeneratorVariable variable, long value)
Assigns a long integer value to the specified variable The value is zero-extended to suit the variable size.protected void
setValue(DataGeneratorVariable variable, java.math.BigInteger value)
Assigns aBigInteger
value to the specified variable.protected void
setValue(DataGeneratorVariable variable, ru.ispras.fortress.data.Data value)
Assigns aData
value to the specified variable.protected void
setValue(DataGeneratorVariable variable, ru.ispras.fortress.data.types.bitvector.BitVector value)
Assigns aBitVector
value to the specified variable.protected void
setValue(DataGeneratorVariable variable, ru.ispras.fortress.expression.NodeValue value)
Assigns aNodeValue
value to the specified variable.protected void
setValue(DataGeneratorVariable variable, Iterator<ru.ispras.fortress.expression.NodeValue> values)
Assigns aNodeValue
iterator to the specified variable.
-
-
-
Constructor Detail
-
DataGeneratorBase
public DataGeneratorBase(java.lang.String name, java.util.Set<java.lang.String> instructions)
Constructs a data generator with the specified name applicable to the specified instructions.- Parameters:
name
- Data generator name.instructions
- Names of instructions the generator is applicable to. If it equalsnull
, the generator is applicable to all instructions.- Throws:
java.lang.IllegalArgumentException
- ifname
isnull
.
-
DataGeneratorBase
public DataGeneratorBase(java.lang.String name)
Constructs a data generator with the specified name applicable to all instructions.- Parameters:
name
- Data generator name.- Throws:
java.lang.IllegalArgumentException
- ifname
isnull
.
-
-
Method Detail
-
getName
public final java.lang.String getName()
Returns data generator name.- Returns:
- Name identifying the data generator.
-
isSuitable
public boolean isSuitable(TestBaseQuery query)
Checks whether the data generator is capable of generating data for the specified query.The generator is considered suitable if two conditions are satisfied:
- the generator name matches the test case name specified in the query;
- the instruction name specified in the query is in the set of supported instructions
(skipped if the set is
null
).
- Specified by:
isSuitable
in interfaceDataGenerator
- Parameters:
query
- Query to be processed.- Returns:
true
if the query can be handled by the generator orfalse
otherwise.
-
generate
public final Iterator<TestData> generate(TestBaseQuery query)
Description copied from interface:DataGenerator
Generates data for the specified query.- Specified by:
generate
in interfaceDataGenerator
- Parameters:
query
- Query to be processed.- Returns:
- Iterator over the generated test data.
-
generate
protected abstract void generate(DataGeneratorQuery query)
Generates data for the specified data generator query. Generated values are assigned to the query variables.- Parameters:
query
- Data generator query to be processed.
-
setValue
protected final void setValue(DataGeneratorVariable variable, int value)
Assigns an integer value to the specified variable. The value is zero-extended to suit the variable size.- Parameters:
variable
- Variable to be assigned a value.value
- Value to be assigned.- Throws:
java.lang.IllegalArgumentException
- if thevariable
argument isnull
; if the variable already has a value; if the value type does not match the variable type.
-
setValue
protected final void setValue(DataGeneratorVariable variable, long value)
Assigns a long integer value to the specified variable The value is zero-extended to suit the variable size.- Parameters:
variable
- Variable to be assigned a value.value
- Value to be assigned.- Throws:
java.lang.IllegalArgumentException
- if thevariable
argument isnull
; if the variable already has a value; if the value type does not match the variable type.
-
setValue
protected final void setValue(DataGeneratorVariable variable, java.math.BigInteger value)
Assigns aBigInteger
value to the specified variable.- Parameters:
variable
- Variable to be assigned a value.value
- Value to be assigned.- Throws:
java.lang.IllegalArgumentException
- if any of the arguments isnull
; if the variable already has a value; if the value type does not match the variable type.
-
setValue
protected final void setValue(DataGeneratorVariable variable, ru.ispras.fortress.data.types.bitvector.BitVector value)
Assigns aBitVector
value to the specified variable.- Parameters:
variable
- Variable to be assigned a value.value
- Value to be assigned.- Throws:
java.lang.IllegalArgumentException
- if any of the arguments isnull
; if the variable already has a value; if the value size does not match the variable size.
-
setValue
protected final void setValue(DataGeneratorVariable variable, ru.ispras.fortress.data.Data value)
Assigns aData
value to the specified variable.- Parameters:
variable
- Variable to be assigned a value.value
- Value to be assigned.- Throws:
java.lang.IllegalArgumentException
- if the argument isnull
; if the variable already has a value; if the value type does not match the variable type.
-
setValue
protected final void setValue(DataGeneratorVariable variable, ru.ispras.fortress.expression.NodeValue value)
Assigns aNodeValue
value to the specified variable.- Parameters:
variable
- Variable to be assigned a value.value
- Value to be assigned.- Throws:
java.lang.IllegalArgumentException
- if any of the arguments isnull
; if the variable already has a value.
-
setValue
protected final void setValue(DataGeneratorVariable variable, Iterator<ru.ispras.fortress.expression.NodeValue> values)
Assigns aNodeValue
iterator to the specified variable.- Parameters:
variable
- Variable to be assigned a value.values
- Value iterator to be assigned.- Throws:
java.lang.IllegalArgumentException
- if any of the arguments isnull
; if the variable already has a value; if the value iterator is empty.
-
-