jcreek.representation.constraints
Class CardinalityConstraintObject

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

public class CardinalityConstraintObject
extends ConstraintObject

Handles the behaviour of Cardinality constraints.

Offers the ability from define cardinality constraints for the relations of a given type for some entity. Two integer values, max and min defines the maximum and minimum cardinality.

Author:
Martin Stige
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jcreek.representation.constraints.ConstraintObject
km, rel
 
Constructor Summary
CardinalityConstraintObject(RelationType rel, int numberMin, int numberMax)
          Creates a new instance of Cardinality The entity from must have minimum numberMin and maximum numberMax values for the slot/relation rel
 
Method Summary
 ConstraintCheckResult check(Entity from)
          Checks whether the constraint is violated or not.
protected  int getMax()
          Returns the max cardinality
protected  int getMin()
          Returns the min cardinality
 Constraint newConstraintInstance(KnowledgeModel km, ConstraintData data)
          Creates a Cardinality constraint object
protected  void setMax(int m)
          Sets the max cardinality
protected  void setMin(int m)
          Sets the min cardinality
 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

CardinalityConstraintObject

public CardinalityConstraintObject(RelationType rel,
                                   int numberMin,
                                   int numberMax)
Creates a new instance of Cardinality

The entity from must have minimum numberMin and maximum numberMax values for the slot/relation rel

Parameters:
rel - the RelationType being constraind
numberMin - the minimum number of values
numberMax - the maximum number of values
Method Detail

check

public ConstraintCheckResult check(Entity from)
Description copied from class: ConstraintObject
Checks whether the constraint is violated or not.

Should be augmented to offer some feedback about the violations. Until that is made, feedback is just printed to System.out.

Specified by:
check in class ConstraintObject
Returns:
true if everyting is ok, false if the constraint is violated

toString

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

getMax

protected int getMax()
Returns the max cardinality

Returns:
the max cardinality value

getMin

protected int getMin()
Returns the min cardinality

Returns:
the max cardinality value

setMax

protected void setMax(int m)
Sets the max cardinality

Parameters:
m - the max cardinality value

setMin

protected void setMin(int m)
Sets the min cardinality

Parameters:
m - the min cardinality value

newConstraintInstance

public Constraint newConstraintInstance(KnowledgeModel km,
                                        ConstraintData data)
Creates a Cardinality constraint object

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


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