jcreek.representation.constraints
Class ConcreteValueConstraintObject

java.lang.Object
  extended byjcreek.representation.constraints.ConstraintObject
      extended byjcreek.representation.constraints.ConcreteValueConstraintObject
All Implemented Interfaces:
java.io.Serializable

public class ConcreteValueConstraintObject
extends ConstraintObject

Handles the behaviour of Concrete value constraints.

Offers the ability to define constraints based on concrete values. You can either define the closed set of allowed values, or define a set of values that are not allowed.

It is not interresting to define both these two constraints on the same entity->relation. If the (positive) allowed is used, all values not on the list are implicitly defined as disallowed.
If the (negative) disallowed is used all values not on the list are allowed.

Author:
Martin Stige
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jcreek.representation.constraints.ConstraintObject
km, rel
 
Constructor Summary
ConcreteValueConstraintObject(RelationType rel, java.util.ArrayList values, boolean allowed)
          Creates a new instance of ConcreteValueConstraintObject Defines a list of values/entities that are either allowed or dissallowed as a value for a relation on an entity.
 
Method Summary
protected  void addValue(Entity val)
          Adds a new value to the allowed/dissallowed list
 ConstraintCheckResult check(Entity from)
          Checks the constraint
protected  boolean getAllowed()
          Returns whether the values are allowed or not
true = allowed, false = disallowed
protected  java.util.ArrayList getValues()
          Returns the values that are allowed or disallowed
 Constraint newConstraintInstance(KnowledgeModel km, ConstraintData data)
          Creates a ConcretValueConstraint object from a ConstraintData object
protected  void setAllowed(boolean b)
          Sets wheter the list of values are allowed or not
protected  void setValues(java.util.ArrayList a)
          Sets the list of values
 java.lang.String toString()
           
 
Methods inherited from class jcreek.representation.constraints.ConstraintObject
getRelation, setKnowledgeModel, setRelation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConcreteValueConstraintObject

public ConcreteValueConstraintObject(RelationType rel,
                                     java.util.ArrayList values,
                                     boolean allowed)
Creates a new instance of ConcreteValueConstraintObject Defines a list of values/entities that are either allowed or dissallowed as a value for a relation on an entity.

Meaning of constraint: The values in the list are allowed/dissallowed as the values of relations of type rel from entity from

Parameters:
rel - the relation type being restricted
values - the values allowed or dissallowed
allowed - descides whether the values are allowed or dissallowed
Method Detail

addValue

protected void addValue(Entity val)
Adds a new value to the allowed/dissallowed list

Parameters:
val - the value to be added

check

public ConstraintCheckResult check(Entity from)
Checks the constraint

Specified by:
check in class ConstraintObject
Parameters:
from - the entity that are constrained
Returns:
true if everyting is ok, false if the constraint is violated

getValues

protected java.util.ArrayList getValues()
Returns the values that are allowed or disallowed


getAllowed

protected boolean getAllowed()
Returns whether the values are allowed or not
true = allowed, false = disallowed


setValues

protected void setValues(java.util.ArrayList a)
Sets the list of values

Parameters:
a - the list of values

setAllowed

protected void setAllowed(boolean b)
Sets wheter the list of values are allowed or not


newConstraintInstance

public Constraint newConstraintInstance(KnowledgeModel km,
                                        ConstraintData data)
Creates a ConcretValueConstraint object from a ConstraintData object

Specified by:
newConstraintInstance in class ConstraintObject
Parameters:
km - the knowledge model
data - the constraint data to be contained by the constraint

toString

public java.lang.String toString()
Specified by:
toString in class ConstraintObject


Created at IDI, NTNU by the Artificial Intelligence and Learning group