com.monad.homerun.rule
Class Rule

java.lang.Object
  extended by com.monad.homerun.base.DataObject
      extended by com.monad.homerun.rule.Rule
All Implemented Interfaces:
java.io.Serializable

public class Rule
extends DataObject

A Rule is an ordered list of Clauses, minimum one. When a rule is applied, each clause in turn is applied, in the fashion of: if (first clause) else if (second clause), etc

See Also:
Serialized Form

Constructor Summary
Rule()
           
Rule(java.lang.String name, java.lang.String category)
           
Rule(java.lang.String name, java.lang.String category, Rule rule)
           
 
Method Summary
 void addClause(Clause clause)
          Adds a clause to the rule
 void apply(java.util.Map<java.lang.String,java.lang.Object> context)
          Applies the rule in the current context
 java.util.List<java.lang.String> getBindingVariables()
          Gets a list of any binding variables in Rule
 java.util.List<java.lang.String> getBindingVariables(java.util.Map<java.lang.String,java.lang.Object> context)
          Gets a list of any binding variables in Rule
 Clause getClause(int index)
          Returns the clause at the specified index
 int getNumClauses()
          Returns the number of clauses in the rule
 boolean isAppliable()
          Can the rule be applied (does it have any conditions), as opposed to just performed ?
 boolean isStartable(Invoker invoker)
          Can the rule be started? (as opposed to just executed/run)
 void removeClause(int index)
          Removes a clause from the rule at specified index
 boolean validate(java.util.Map<java.lang.String,java.lang.Object> context)
           
 
Methods inherited from class com.monad.homerun.base.DataObject
getCategory, getModificationTime, getName, getNote, setCategory, setModificationTime, setName, setNote
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rule

public Rule()

Rule

public Rule(java.lang.String name,
            java.lang.String category)

Rule

public Rule(java.lang.String name,
            java.lang.String category,
            Rule rule)
Method Detail

addClause

public final void addClause(Clause clause)
Adds a clause to the rule

Parameters:
clause -

removeClause

public void removeClause(int index)
Removes a clause from the rule at specified index

Parameters:
index -

isStartable

public boolean isStartable(Invoker invoker)
Can the rule be started? (as opposed to just executed/run)


isAppliable

public boolean isAppliable()
Can the rule be applied (does it have any conditions), as opposed to just performed ?


validate

public boolean validate(java.util.Map<java.lang.String,java.lang.Object> context)

apply

public void apply(java.util.Map<java.lang.String,java.lang.Object> context)
           throws NoResourceException
Applies the rule in the current context

Parameters:
context - the invocation context
Throws:
NoResourceException

getNumClauses

public int getNumClauses()
Returns the number of clauses in the rule

Returns:
num the number of clauses

getClause

public Clause getClause(int index)
Returns the clause at the specified index

Parameters:
index - the index into the clause list
Returns:
clause the Clause object

getBindingVariables

public java.util.List<java.lang.String> getBindingVariables()
Gets a list of any binding variables in Rule


getBindingVariables

public java.util.List<java.lang.String> getBindingVariables(java.util.Map<java.lang.String,java.lang.Object> context)
Gets a list of any binding variables in Rule



Copyright © 2006-2009 Richard Rodgers. All Rights Reserved.