policyMgmt
Class Rule

java.lang.Object
  |
  +--policyMgmt.Rule

public class Rule
extends java.lang.Object

Base class for Rules.


Constructor Summary
Rule()
          Create a Rule with default priority of 0.
Rule(int priority)
          Create a Rule with a given priority.
 
Method Summary
 void addAction(Action act)
          Add a new Action to this Rule.
 void addCondition(Condition cond)
          Add a new Condition to this Rule.
 void addFreeIdent(java.lang.String name, java.lang.String classname)
          Declare a given new name as a free Element identifier of an Element of a given class name.
 void doActions(Event evt, java.util.Hashtable unify)
          Execute all Actions of this Rule.
 java.util.Hashtable getFreeIdents()
          Return a Hashtable of the declared free Element identifiers.
 int getPriority()
          Return the priority of this rule.
 java.lang.Object getTrigger()
          Return the trigger for this Rule
 boolean isConditions(Event evt, java.util.Hashtable unify)
          Return true, if all Conditions are true.
 void setTrigger(java.lang.Object trigger)
          Set the trigger for this Rule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rule

public Rule()
Create a Rule with default priority of 0.

Rule

public Rule(int priority)
Create a Rule with a given priority.
Parameters:
priority - the priority of this newly created Rule
Method Detail

getPriority

public int getPriority()
Return the priority of this rule.
Returns:
this Rule's priority

addFreeIdent

public void addFreeIdent(java.lang.String name,
                         java.lang.String classname)
Declare a given new name as a free Element identifier of an Element of a given class name. This name binding is used for all subsequent calls to methods of the Condition and Action.
Parameters:
name - the unique key of the new free Element identifier
classname - the name of the associated Element class b

getFreeIdents

public java.util.Hashtable getFreeIdents()
Return a Hashtable of the declared free Element identifiers.
Returns:
the Hashtable of free identifiers

addCondition

public void addCondition(Condition cond)
Add a new Condition to this Rule. All Conditions are ORed, i.e. a single Condition need to be evaluated to true to execute the Rule's Action.
Parameters:
cond - the new Condition

addAction

public void addAction(Action act)
Add a new Action to this Rule. If the Actions come to execution, all of them are processed, even if previous Actions fail with exceptions.

isConditions

public boolean isConditions(Event evt,
                            java.util.Hashtable unify)
Return true, if all Conditions are true.
Parameters:
evt - the triggering Event
unify - the Hashtable of assiciated Elements
Returns:
the ANDed result of all Conditions

doActions

public void doActions(Event evt,
                      java.util.Hashtable unify)
Execute all Actions of this Rule.
Parameters:
evt - the triggering Event
unify - the Hashtable of assiciated Elements

setTrigger

public void setTrigger(java.lang.Object trigger)
Set the trigger for this Rule
Parameters:
trigger - the triggering Object of this Rule

getTrigger

public java.lang.Object getTrigger()
Return the trigger for this Rule
Returns:
the triggering Object of this Rule