JET

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

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

 class ClassValueGenerator
extends Object

A class to generate class values.

Version:
$Revision: 1.21 $
Author:
Yoonsik Cheon

Field Summary
private  List<Constructor> constructors
          Constructors of the class under test.
protected  Context context
          The testing context.
private  ValueFactory factory
          Factory to create various types of values.
private  ValueGenerator generator
          Generator to generate various types of values randomly.
private  List<Method> mutators
          Mutators of the class under test.
private  List<Method> staticConstructors
          Static constructors 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.
private  Denotable[] generateArguments(Class[] types, int maxHeight)
          Generates arguments of the given types.
private  boolean isConstructor(Constructor c)
          Returns true if the given constructor is a constructor that can be used to build an object dynamically.
private  boolean isMutator(Method m)
          Returns true if the given method is a mutator.
private  boolean isStaticConstructor(Method m)
          Returns true if the given method is a basic static constructor.
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.
 
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.


staticConstructors

private List<Method> staticConstructors
Static constructors of the class under test.


constructors

private List<Constructor> constructors
Constructors of the class under test.


mutators

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


generator

private final ValueGenerator generator
Generator to generate various types of values randomly.


factory

private 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
mutate - True if the object has already been mutated
maxHeight - Maximum height of the mutated object (viewed as a tree)

createNullValue

protected Denotable createNullValue()
Creates a null value.


generateArguments

private Denotable[] generateArguments(Class[] types,
                                      int maxHeight)
Generates arguments of the given types.

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

isStaticConstructor

private boolean isStaticConstructor(Method m)
Returns true if the given method is a basic static constructor.


isConstructor

private boolean isConstructor(Constructor c)
Returns true if the given constructor is a constructor that can be used to build an object dynamically. It should be public and non-abstract.


isMutator

private boolean isMutator(Method m)
Returns true if the given method is a mutator. A non-static method is a mutator if its return type is void.


JET

JET is Copyright (C) 2005-2007 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.