drvgraph.j2d
Class SlotPattern

java.lang.Object
  extended by drvgraph.j2d.SlotPattern
All Implemented Interfaces:
java.lang.Comparable

public class SlotPattern
extends java.lang.Object
implements java.lang.Comparable

Represents the slot pattern. Slot patterns represent conditions on slots (or class properties).
Slot patterns consist of a slot name, a variable and a list of value constraints. The variable in the slot pattern is used, in order for the slot value to be unified, with the latter having to satisfy the list of constraints. The argument list of each slot pattern is divided in two parts, separated by ; on the left all the variables are placed and on the right all the corresponding expressions and conditions, regarding the variables on the left. For instance, in the slot pattern age(X|X>18), age is the slot name, X is the variable and X>18 is the constraint.


Constructor Summary
SlotPattern()
          Creates a slot pattern with no name, no variable and and an empty list of constraints.
SlotPattern(java.lang.String sn, java.lang.String var, java.lang.String exp)
          Creates a slot pattern with a defined name, a defined variable and a given list of constraints.
 
Method Summary
 int compareTo(java.lang.Object anotherSp)
          Compares this slot pattern with a given slot pattern.
 java.lang.String getExpression()
          Returns a string that represents the expression, i.e. the list of constraints.
 java.lang.String getName()
          Returns a string that represents the slot name.
 java.lang.String getVar()
          Returns a string that represents the variable.
 void setExpression(java.lang.String exp)
          Sets the expression.
 void setName(java.lang.String name)
          Sets the slot name.
 void setVar(java.lang.String var)
          Sets the variable.
 java.lang.String toString()
          Returns a string representation of this slot pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SlotPattern

public SlotPattern()
Creates a slot pattern with no name, no variable and and an empty list of constraints.


SlotPattern

public SlotPattern(java.lang.String sn,
                   java.lang.String var,
                   java.lang.String exp)
Creates a slot pattern with a defined name, a defined variable and a given list of constraints. Use the empty string "", if you want to leave any of the fields blank.

Parameters:
sn - the slot name string
var - the variable name
exp - the list of constraints
Method Detail

getName

public java.lang.String getName()
Returns a string that represents the slot name.

Returns:
the slot name string

setName

public void setName(java.lang.String name)
Sets the slot name.

Parameters:
name - the string used as the slot name

getVar

public java.lang.String getVar()
Returns a string that represents the variable.

Returns:
the variable string

setVar

public void setVar(java.lang.String var)
Sets the variable.

Parameters:
var - the string used as the variable name

getExpression

public java.lang.String getExpression()
Returns a string that represents the expression, i.e. the list of constraints.

Returns:
the expression string

setExpression

public void setExpression(java.lang.String exp)
Sets the expression.

Parameters:
exp - the string representing the expression

compareTo

public int compareTo(java.lang.Object anotherSp)
              throws java.lang.ClassCastException
Compares this slot pattern with a given slot pattern.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
anotherSp - the slot pattern to compare this slot pattern to
Returns:
the comparison outcome: 0 if the two slot patterns are identical, -1 otherwise
Throws:
java.lang.ClassCastException - A ClassCastException is thrown if the Object to compare this object to belongs to a different class.

toString

public java.lang.String toString()
Returns a string representation of this slot pattern. This method is needed, when the slot pattern is drawn.

Overrides:
toString in class java.lang.Object
Returns:
a string representing this slot pattern