de.upb.swt.mcie.robdds
Class HashAssignment

java.lang.Object
  extended by de.upb.swt.mcie.robdds.HashAssignment
All Implemented Interfaces:
Assignment

public class HashAssignment
extends java.lang.Object
implements Assignment

This class implements an Assignment. It is realized as a HashMap, which maps some variables to an Integer value.

Author:
Ekkart Kindler, kindler@upb.de

Field Summary
private  java.util.HashMap assignment
          The mapping representing the assignment.
private  Context context
          The context of the assignment.
 
Constructor Summary
HashAssignment(Context context)
          Constructs an empty assignment, i.e. a mapping that assigns don't care values (null) to each variable.
 
Method Summary
 Context getContext()
          Returns the context of the assignment.
 int getValue(Variable variable)
          Returns the value of the assignment for the variable.
 void setValue(Variable variable, int value)
          Adds a value for a variable to the assignment.
 java.lang.String toString()
          Returns the string representation of the assignment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

context

private Context context
The context of the assignment.


assignment

private java.util.HashMap assignment
The mapping representing the assignment.

Constructor Detail

HashAssignment

public HashAssignment(Context context)
Constructs an empty assignment, i.e. a mapping that assigns don't care values (null) to each variable.

Method Detail

getContext

public Context getContext()
Returns the context of the assignment.

Specified by:
getContext in interface Assignment
Returns:
the context of this assignment

setValue

public void setValue(Variable variable,
                     int value)
Adds a value for a variable to the assignment. It is an error, if the variable is from a different context than the assignment.

Specified by:
setValue in interface Assignment
Parameters:
variable - the variable
value - its value
Throws:
IncorrectUseException - if the variable is from a different context than the assignment

getValue

public int getValue(Variable variable)
Returns the value of the assignment for the variable. Any other value than 0 or 1 should be interpreted as undefined. It is an error, if the variable is from a different context than the assignment.

Specified by:
getValue in interface Assignment
Parameters:
variable - variable for which the assigned value should be returned
Returns:
the value assigned to the variable
Throws:
IncorrectUseException - if the variable is from a different context than the assignment

toString

public java.lang.String toString()
Returns the string representation of the assignment. Its implementation is not too sophisticated; but it helps to quickly show an assignment to a user.

Overrides:
toString in class java.lang.Object