Algernon Software

org.algernon.rule
Class Rule

java.lang.Object
  extended byorg.jatha.dynatype.StandardLispValue
      extended byorg.algernon.rule.Rule
All Implemented Interfaces:
Comparable, Displayable, LispValue

public class Rule
extends StandardLispValue
implements Displayable

This class represents a Rule in the AAM. It consists of an antecedent, a direction, a consequent and a key.


Field Summary
protected  LispValue BACKWARD
           
protected  Algernon f_algy
           
protected  LispValue FORWARD
           
protected  Path m_antecedent
           
protected  Collection m_code
           
protected  Path m_consequent
           
protected  int m_direction
           
protected  int m_index
           
protected  Clause m_key
           
protected  String m_name
           
static DecimalFormat m_nameFormat
           
protected  Rule m_root
           
protected  int m_type
           
protected static int ruleCounter
           
 
Fields inherited from class org.jatha.dynatype.StandardLispValue
f_lisp
 
Constructor Summary
Rule(Algernon algy, LispValue ruleForm, int type, Rule root)
          Create a new Algernon Rule
Rule(Algernon algy, String name, LispValue ruleForm, int type, Rule root)
          Create a new Algernon Rule
Rule(Algernon algy, String name, Path antecedent, int direction, Path consequent, Clause key, int type, Rule root)
          Create a new Algernon Rule
 
Method Summary
 String continuationRuleName(int index)
          Returns a string containing the name of a continuation rule.
 String display(PrintStream out)
          Displayable interface.
 LispValue findBCRuleCode(Processor processor, AlgernonKBSet kbSet, BindingList boundVariables)
          Returns the compiled code that is appropriate for the set of bound variables passed in.
 Collection getAllCode()
           
 Path getAntecedent()
          Returns the direction of the rule.
 LispValue getCode()
          Returns the code for a forward chaining rule, or for a backward chaining rule with no bound variables.
 LispValue getCode(Processor processor, AlgernonKBSet kbSet, BindingList bindings)
          Returns the code for a forward chaining rule, or for a backward chaining rule with no bound variables.
 Path getConsequent()
           
 int getDirection()
           
 int getIndex()
           
 Clause getKey()
           
 String getName()
           
static DecimalFormat getNameFormat()
           
 Rule getRoot()
           
 int getType()
           
 boolean isBackwardChaining()
          Returns true if this rule is a backward-chaining rule.
 boolean isForwardChaining()
          Returns true if this rule is a forward-chaining rule.
 void setAntecedent(Path antecedent)
           
 void setCode(Collection code)
           
 void setConsequent(Path consequent)
           
 void setDirection(int direction)
           
 void setIndex(int index)
           
 void setKey(Clause key)
           
 void setName(String name)
           
static void setNameFormat(DecimalFormat nameFormat)
           
 void setRoot(Rule root)
           
 void setType(int type)
           
 String toString()
           
 
Methods inherited from class org.jatha.dynatype.StandardLispValue
abs, acos, add, adjustSpecialCount, append, apply, apropos_print, asin, assoc, atan, atan2, atom, basic_atom, basic_bignump, basic_consp, basic_constantp, basic_floatp, basic_foreignp, basic_functionp, basic_integerp, basic_keywordp, basic_length, basic_listp, basic_macrop, basic_null, basic_numberp, basic_stringp, basic_symbolp, bignump, boundp, butlast, car, cdr, ceiling, characterp, clrhash, compareTo, concatenate, consp, constantp, contains, copy_list, copy, cos, cot, csc, degreesToRadians, divide, eighth, elt, elt, eq, eql, equal, equalNumeric, factorial, fboundp, fifth, first, floatp, floor, fourth, funcall, functionp, get_specialCount, gethash, gethash, getLisp, greaterThan, greaterThanOrEqual, hash_table_count, hash_table_rehash_size, hash_table_rehash_threshold, hash_table_size, hash_table_test, hashtablep, integerp, internal_getName, internal_prin1_as_cdr, internal_prin1, internal_princ_as_cdr, internal_princ, internal_print_as_cdr, internal_print, iterator, keywordp, last, length, lessThan, lessThanOrEqual, lisp_null, list, listp, max, member, min, multiply, nconc, negate, neql, ninth, nreverse, nstringCapitalize, nstringDowncase, nstringUpcase, numberp, pop, position, prin1, princ, print, push, radiansToDegrees, rassoc, reciprocal, remhash, remove, rest, reverse, rplaca, rplacd, sec, second, set_special, setf_gethash, setf_symbol_function, setf_symbol_plist, setf_symbol_value, setLisp, setPackage, setq, seventh, sin, sixth, specialP, sqrt, string, stringCapitalize, stringDowncase, stringEndsWith, stringEq, stringEqual, stringGreaterP, stringGreaterThan, stringGreaterThanOrEqual, stringLeftTrim, stringLeftTrim, stringLessP, stringLessThan, stringLessThanOrEqual, stringNeq, stringNotGreaterP, stringNotLessP, stringp, stringRightTrim, stringRightTrim, stringStartsWith, stringTrim, stringTrim, stringUpcase, subst, substring, substring, subtract, symbol_function, symbol_name, symbol_package, symbol_plist, symbol_value, symbolp, tan, tenth, third, toCollection, toJava, toJava, toString, toStringAsCdr_internal, toStringAsCdr, toStringShort, toStringShort, toStringSimple, type_of, typep, zerop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FORWARD

protected LispValue FORWARD

BACKWARD

protected LispValue BACKWARD

f_algy

protected Algernon f_algy

m_antecedent

protected Path m_antecedent

m_code

protected Collection m_code

m_consequent

protected Path m_consequent

m_direction

protected int m_direction

m_index

protected int m_index

m_key

protected Clause m_key

m_name

protected String m_name

m_root

protected Rule m_root

m_type

protected int m_type

m_nameFormat

public static DecimalFormat m_nameFormat

ruleCounter

protected static int ruleCounter
Constructor Detail

Rule

public Rule(Algernon algy,
            LispValue ruleForm,
            int type,
            Rule root)
     throws AlgernonDataException
Create a new Algernon Rule


Rule

public Rule(Algernon algy,
            String name,
            LispValue ruleForm,
            int type,
            Rule root)
     throws AlgernonDataException
Create a new Algernon Rule


Rule

public Rule(Algernon algy,
            String name,
            Path antecedent,
            int direction,
            Path consequent,
            Clause key,
            int type,
            Rule root)
Create a new Algernon Rule

Method Detail

toString

public String toString()
Specified by:
toString in interface LispValue

display

public String display(PrintStream out)
Displayable interface. If the outputstream is specified, the string is written to the output AND returned in a String. If the output stream is null, it just returns a string.

Specified by:
display in interface Displayable

getName

public String getName()

isForwardChaining

public boolean isForwardChaining()
Returns true if this rule is a forward-chaining rule.


isBackwardChaining

public boolean isBackwardChaining()
Returns true if this rule is a backward-chaining rule.


findBCRuleCode

public LispValue findBCRuleCode(Processor processor,
                                AlgernonKBSet kbSet,
                                BindingList boundVariables)
Returns the compiled code that is appropriate for the set of bound variables passed in.


continuationRuleName

public String continuationRuleName(int index)
Returns a string containing the name of a continuation rule.


getAntecedent

public Path getAntecedent()
Returns the direction of the rule.


setAntecedent

public void setAntecedent(Path antecedent)

getAllCode

public Collection getAllCode()

getCode

public LispValue getCode()
Returns the code for a forward chaining rule, or for a backward chaining rule with no bound variables.


getCode

public LispValue getCode(Processor processor,
                         AlgernonKBSet kbSet,
                         BindingList bindings)
Returns the code for a forward chaining rule, or for a backward chaining rule with no bound variables.


setCode

public void setCode(Collection code)

getConsequent

public Path getConsequent()

setConsequent

public void setConsequent(Path consequent)

getDirection

public int getDirection()

setDirection

public void setDirection(int direction)

getKey

public Clause getKey()

setKey

public void setKey(Clause key)

setName

public void setName(String name)

getType

public int getType()

setType

public void setType(int type)

getNameFormat

public static DecimalFormat getNameFormat()

setNameFormat

public static void setNameFormat(DecimalFormat nameFormat)

getIndex

public int getIndex()

setIndex

public void setIndex(int index)

getRoot

public Rule getRoot()

setRoot

public void setRoot(Rule root)

Algernon Software