com.newisys.randsolver
Class Solver

java.lang.Object
  extended by com.newisys.randsolver.Solver

public class Solver
extends Object

The Jove random constraint solver.


Field Summary
static com.newisys.langschema.constraint.ConsSchema schema
           
 
Constructor Summary
Solver(com.newisys.randsolver.RandInfo randInfo)
           
 
Method Summary
static void disableAllConstraints(Object o)
          Disables all constraints for the specified Object instance.
static void disableAllRand(Object o)
          Disables all random variables for the specified Object instance.
static boolean disableConstraint(Object o, String constraintName)
          Disables the specified constraint for the specified Object instance.
static boolean disableRand(Object o, String varName)
          Disables the specified random variable for the specified Object instance.
static void enableAllConstraints(Object o)
          Enables all constraints for the specified Object instance.
static void enableAllRand(Object o)
          Enables all random variables for the specified Object instance.
static boolean enableConstraint(Object o, String constraintName)
          Enables the specified constraint for the specified Object instance.
static boolean enableRand(Object o, String varName)
          Enables the specified random variable for the specified Object instance.
 void execute(Object obj, com.newisys.randsolver.RandInfo rInfo, PRNG randomStream)
           
static boolean isConstraintEnabled(Object o, String constraintName)
          Returns whether or not the specified constraint will be used when the specified object is randomized.
static boolean isRandEnabled(Object o, String varName)
          Returns whether or not the specified random variable will be randomized when the specified object is randomized.
static void randomize(Object obj, PRNG randomStream)
           
static
<E extends Enum<E>>
E
randomizeEnumType(Class<E> enumType, PRNG randomStream)
          Returns a random instance of the specified enumeration.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schema

public static final com.newisys.langschema.constraint.ConsSchema schema
Constructor Detail

Solver

public Solver(com.newisys.randsolver.RandInfo randInfo)
Method Detail

randomizeEnumType

public static <E extends Enum<E>> E randomizeEnumType(Class<E> enumType,
                                                      PRNG randomStream)
Returns a random instance of the specified enumeration. This randomization will respect any RandExclude annotations included in the enumeration.

Type Parameters:
E - the enumeration type to randomize
Parameters:
enumType - the enumeration type to randomize
randomStream - the PRNG to use when randomizing
Returns:
a random instance of type enumType

randomize

public static void randomize(Object obj,
                             PRNG randomStream)

execute

public void execute(Object obj,
                    com.newisys.randsolver.RandInfo rInfo,
                    PRNG randomStream)

isRandEnabled

public static boolean isRandEnabled(Object o,
                                    String varName)
Returns whether or not the specified random variable will be randomized when the specified object is randomized. If the variable will be randomized, true is returned. Otherwise false is returned.

Parameters:
o - the object containing the random variable
varName - the name of the variable to check
Returns:
true if the variable is enabled, false otherwise

enableAllRand

public static void enableAllRand(Object o)
Enables all random variables for the specified Object instance. All variables in the Object instance annotated with either Rand or Randc will be enabled.

Parameters:
o - the Object instance in which to enable all random variables

enableRand

public static boolean enableRand(Object o,
                                 String varName)
Enables the specified random variable for the specified Object instance. It is harmless to call this method if the variable is already enabled. The method returns whether or not the variable was enabled prior to the method being called.

Parameters:
o - the Object instance in which to enable the random variable
varName - a String containing the name of the variable to enable in o
Returns:
true if the variable was enabled prior to enableRand being called, false otherwise.
Throws:
InvalidRandomVarException - if varName doesn't exist in o

disableAllRand

public static void disableAllRand(Object o)
Disables all random variables for the specified Object instance. All variables in the Object instance annotated with either Rand or Randc will be disabled.

Parameters:
o - the Object instance in which to disable all random variables

disableRand

public static boolean disableRand(Object o,
                                  String varName)
Disables the specified random variable for the specified Object instance. It is harmless to call this method if the variable is already disabled. The method returns whether or not the variable was disabled prior to the method being called.

Parameters:
o - the Object instance in which to disable the random variable
varName - a String containing the name of the variable to disable in o
Returns:
true if the variable was disabled prior to disableRand being called, false otherwise.
Throws:
InvalidRandomVarException - if varName doesn't exist in o

isConstraintEnabled

public static boolean isConstraintEnabled(Object o,
                                          String constraintName)
Returns whether or not the specified constraint will be used when the specified object is randomized. If the constraint will be used, true is returned. Otherwise false is returned.

Parameters:
o - the object containing the constraint
constraintName - the name of the constraint to check
Returns:
true if the constraint is enabled, false otherwise

enableAllConstraints

public static void enableAllConstraints(Object o)
Enables all constraints for the specified Object instance. All constraints on the Object instance annotated with Constraint will be enabled.

Parameters:
o - the Object instance in which to enable all constraints

enableConstraint

public static boolean enableConstraint(Object o,
                                       String constraintName)
Enables the specified constraint for the specified Object instance. It is harmless to call this method if the constraint is already enabled. The method returns whether or not the constraint was enabled prior to the method being called. To use this API, classes should specify names in their Constraint annotations.

Parameters:
o - the Object instance in which to enable the constraint
constraintName - a String containing the name of the constraint to enable in o
Returns:
true if the constraint was enabled prior to enableConstraint being called, false otherwise.
Throws:
InvalidConstraintException - if constraintName doesn't exist in o

disableAllConstraints

public static void disableAllConstraints(Object o)
Disables all constraints for the specified Object instance. All constraints on the Object instance annotated with Constraint will be disabled.

Parameters:
o - the Object instance in which to disable all constraints

disableConstraint

public static boolean disableConstraint(Object o,
                                        String constraintName)
Disables the specified constraint for the specified Object instance. It is harmless to call this method if the constraint is already disabled. The method returns whether or not the constraint was disabled prior to the method being called. To use this API, classes should specify names in their Constraint annotations.

Parameters:
o - the Object instance in which to disable the constraint
constraintName - a String containing the name of the constraint to disable in o
Returns:
true if the constraint was disabled prior to disableConstraint being called, false otherwise.
Throws:
InvalidConstraintException - if constraintName doesn't exist in o