JET

edu.utep.cs.jet.rat.gen
Class ClassValueGenerator

java.lang.Object
  extended by edu.utep.cs.jet.rat.gen.ClassValueGenerator
Direct Known Subclasses:
IncrementalClassValueGenerator

public class ClassValueGenerator
extends Object

A class to generate class values.

Version:
$Revision: 1.28 $
Author:
Yoonsik Cheon

Field Summary
protected  Context context
          The testing context.
protected  ValueFactory factory
          Factory to create various types of values.
protected  List<Method> mutators
          Mutators of the class under test.
protected  Class<?> type
          The class of which a value is to be generated.
 
Constructor Summary
ClassValueGenerator(ValueFactory factory, ValueGenerator generator)
          Creates a generic class generator.
 
Method Summary
protected  Denotable construct(int maxHeight)
          Constructs and returns an instance of the target class.
protected  Denotable createNullValue()
          Creates a null value.
 Denotable generate(Class<?> type, Context ctx, int maxHeight)
          Generates a value of the given class type under the given testing context.
protected  Denotable[] generateArguments(Class<?>[] types, int maxHeight)
          Generates arguments of the given types.
protected  Denotable mutate(Denotable value, double rate, boolean mutated, int maxHeight)
          Mutates the given value by calling a sequence of mutators.
protected  void reset(Class<?> type, Context ctx)
          Reconfigures this object to be able to create an object of the given type in the given testing context.
protected  Denotable simpleMutate(Denotable value, int maxHeight)
          Mutates the given value by calling one of its mutator methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected Context context
The testing context.


type

protected Class<?> type
The class of which a value is to be generated.


mutators

protected List<Method> mutators
Mutators of the class under test.


factory

protected final ValueFactory factory
Factory to create various types of values.

Constructor Detail

ClassValueGenerator

public ClassValueGenerator(ValueFactory factory,
                           ValueGenerator generator)
Creates a generic class generator.

Method Detail

generate

public Denotable generate(Class<?> type,
                          Context ctx,
                          int maxHeight)
Generates a value of the given class type under the given testing context. The height of the returned object, represented as a tree, shouldn't exceed maxHeight to prevent an infinite or excessive recursion.


reset

protected void reset(Class<?> type,
                     Context ctx)
Reconfigures this object to be able to create an object of the given type in the given testing context.


construct

protected Denotable construct(int maxHeight)
Constructs and returns an instance of the target class. The constructed instance may be a null value, and its height (viewed as a tree) shouldn't exceed the given maximum.


mutate

protected Denotable mutate(Denotable value,
                           double rate,
                           boolean mutated,
                           int maxHeight)
Mutates the given value by calling a sequence of mutators.

Parameters:
value - Object to be mutated
rate - Mutation rate
mutated - True if the object has already been mutated
maxHeight - Maximum height of the mutated object (viewed as a tree)

simpleMutate

protected Denotable simpleMutate(Denotable value,
                                 int maxHeight)
Mutates the given value by calling one of its mutator methods.

Parameters:
value - Object to be mutated
maxHeight - Maximum height of the mutated object (viewed as a tree)

createNullValue

protected Denotable createNullValue()
Creates a null value.


generateArguments

protected Denotable[] generateArguments(Class<?>[] types,
                                        int maxHeight)
Generates arguments of the given types.

Parameters:
maxHeight - Maximum height of generated objects (viewed as trees)

JET

JET is Copyright (C) 2005-2008 by The University of Texas at El Paso and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.