CIDER Toolkit
Version 0.1.0-beta

au.edu.monash.csse.tonyj.cider.constraints
Interface ConstraintCompiler


public interface ConstraintCompiler

A constraint compiler allows solver constraint strings to constraint expression strings to be parsed during a compile phase, so they will not need to be parsed during the runtime of the application that uses them. This interface defines how a constraint compiler is used. Classes that implement this interface should also define a no-argument constructor.


Method Summary
 void createConstraintClass(java.lang.String className, java.lang.String classPackage, java.lang.String constraintStr, java.io.PrintWriter output)
          Creates a constraint class.
 void createConstraintExpressionClass(java.lang.String className, java.lang.String classPackage, java.lang.String expressionStr, java.io.PrintWriter output)
          Creates a constraint expression class.
 

Method Detail

createConstraintClass

public void createConstraintClass(java.lang.String className,
                                  java.lang.String classPackage,
                                  java.lang.String constraintStr,
                                  java.io.PrintWriter output)
                           throws CannotProcessConstraintException,
                                  java.lang.NumberFormatException
Creates a constraint class. It first defines the package of the class (unless classPackage is the empty string), then the import statements that are needed, and then the class itself. The class should implement the Constraint interface, or extend another class that already implements this interface.

Inside the class, only the constructor needs to be created. This constructor receives one argument, an array of ConstraintVariables, and also throws an java.lang.ArrayIndexOutOfBoundsException (which is thrown if an illegal access to the array is attempted). Essentially, the constructor works the same as the Constraint.initialize(java.lang.String, au.edu.monash.csse.tonyj.cider.constraints.ConstraintVariable[]) method, except the constructor will be able to create the constraint directly without having to parse a string.

Parameters:
className - The name of the constraint class.
classPackage - The name of the package the constraint class belongs to.
constraintStr - A string that defines the constraint (this string needs to be parsed).
output - The output stream where the class is to be written.
Throws:
CannotProcessConstraintException - If string cannot be parsed.
java.lang.NumberFormatException - If an illegal number format is found in the string being parsed.

createConstraintExpressionClass

public void createConstraintExpressionClass(java.lang.String className,
                                            java.lang.String classPackage,
                                            java.lang.String expressionStr,
                                            java.io.PrintWriter output)
                                     throws CannotProcessConstraintException,
                                            java.lang.NumberFormatException
Creates a constraint expression class. It first defines the package of the class (unless classPackage is the empty string), then the import statements that are needed, and then the class itself. The class should implement the ConstraintExpression interface, or extend another class that already implements this interface.

Inside the class, only the constructor needs to be created. This constructor receives one argument, an array of ConstraintVariables, and also throws an java.lang.ArrayIndexOutOfBoundsException (which is thrown if an illegal access to the array is attempted). Essentially, the constructor works the same as the ConstraintExpression.initialize(java.lang.String, au.edu.monash.csse.tonyj.cider.constraints.ConstraintVariable[]) method, except the constructor will be able to create the constraint directly without having to parse a string.

Parameters:
className - The name of the constraint expression class.
classPackage - The name of the package the constraint expression class belongs to.
expressionStr - A string that defines the constraint expression (this string needs to be parsed).
output - The output stream where the class is to be written.
Throws:
CannotProcessConstraintException - If string cannot be parsed.
java.lang.NumberFormatException - If an illegal number format is found in the string being parsed.

CIDER Toolkit
Version 0.1.0-beta