com.sri.oaa2.icl
Class IclDb

java.lang.Object
  |
  +--com.sri.oaa2.icl.IclDb

public class IclDb
extends java.lang.Object

DataBase class for OAA V2.0


Constructor Summary
IclDb()
          IclDb()
 
Method Summary
 IclTerm asserta(IclTerm inTerm)
          Asserts a new term at the beginning of the table
 IclTerm assertz(IclTerm inTerm)
          Asserts a new term at the end of the table
 boolean db_Assert(IclTerm term, IclTerm params)
          Asserts a new term in the database.
 boolean db_Contains(IclTerm term)
          Checks if a term is stored in the database.
 boolean db_getRef(IclTerm inTerm, IclList inParams, IclList references)
          Fills the incoming list with all internal references of the terms that unify with the incoming one.
 void db_PrintDB()
          Writes out the entire database
 boolean db_Replace(IclTerm newTerm, IclTerm oldTerm, IclTerm params)
          Replaces an ICL term from the database by another one.
 boolean db_Retract(IclTerm term, IclTerm params)
          db_Retract(IclTerm term, IclTerm params)
 boolean db_Retract(IclTerm term, IclTerm params, boolean inDebug)
          Removes an ICL term from the database.
 boolean db_Solve(IclTerm term, IclList params, IclList answer)
          db_Solve(IclTerm term, IclList params, IclList answer)
 boolean db_Solve(IclTerm term, IclList params, IclList answer, boolean getUniqueReferences)
          Searches the database for matches to term.
 boolean db_SolveDebug(IclTerm term, IclList params, IclList answer, boolean getUniqueReferences)
           
 boolean erase(IclTerm inRef)
          Erases the term that is bound to the incoming reference
 boolean replace_all(IclTerm newTerm, IclTerm oldTerm)
          Replaces all occurences that match with oldTerm by newTerm
 boolean retract_all(IclTerm inTerm)
          Removes all terms that unify with inTerm
 boolean retract(IclTerm inTerm)
          Removes the first term that unifies with inTerm
 boolean retract(IclTerm inTerm, boolean inDebug)
           
 java.lang.String toString()
          toString()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IclDb

public IclDb()
IclDb()

Method Detail

db_Assert

public boolean db_Assert(IclTerm term,
                         IclTerm params)
Asserts a new term in the database. Adds a copy of ICL term into the database

parameters may include "at_beginning" (boolean parameter)

Returns:
true if success

db_Assert(my_pred(a,B),[at_begining(true)])


db_Solve

public boolean db_Solve(IclTerm term,
                        IclList params,
                        IclList answer,
                        boolean getUniqueReferences)
Searches the database for matches to term. Fills the incoming IclList with the answers. If the incoming IclList is null, db_Solve will return true if one term of the DB unifies with the incoming one.

Parameters may include "solution_limit" (integer parameter)

 
  Example: 
   db_Solve(my_pred(a,B),[solution_limit(10)])	 
 

Returns:
False if fail.

db_SolveDebug

public boolean db_SolveDebug(IclTerm term,
                             IclList params,
                             IclList answer,
                             boolean getUniqueReferences)

db_Solve

public boolean db_Solve(IclTerm term,
                        IclList params,
                        IclList answer)
db_Solve(IclTerm term, IclList params, IclList answer)


db_Contains

public boolean db_Contains(IclTerm term)
Checks if a term is stored in the database. Based on db_Solve.

Returns:
true if success

db_Retract

public boolean db_Retract(IclTerm term,
                          IclTerm params,
                          boolean inDebug)
Removes an ICL term from the database. Parameters may include "do_all" (boolean parameter).
 
 examples : 
   db_Retract(my_pred(a,B),[do_all(true)])	 
 

Returns:
true if success

db_Replace

public boolean db_Replace(IclTerm newTerm,
                          IclTerm oldTerm,
                          IclTerm params)
Replaces an ICL term from the database by another one. Parameters may include "do_all" (boolean parameter)

Returns:
true if success
 
 examples : 
   db_Replace(old_pred(a,B), new_pred(X), [do_all(true)])	 
 

db_Retract

public boolean db_Retract(IclTerm term,
                          IclTerm params)
db_Retract(IclTerm term, IclTerm params)


db_PrintDB

public void db_PrintDB()
Writes out the entire database


toString

public java.lang.String toString()
toString()

Overrides:
toString in class java.lang.Object

asserta

public IclTerm asserta(IclTerm inTerm)
Asserts a new term at the beginning of the table

Returns:
A unique reference to this specific assertion

assertz

public IclTerm assertz(IclTerm inTerm)
Asserts a new term at the end of the table

Returns:
A unique reference to this specific assertion

retract

public boolean retract(IclTerm inTerm)
Removes the first term that unifies with inTerm

Returns:
True if one term was actually retracted

retract

public boolean retract(IclTerm inTerm,
                       boolean inDebug)

retract_all

public boolean retract_all(IclTerm inTerm)
Removes all terms that unify with inTerm

Returns:
True if at least one term was actually retracted

replace_all

public boolean replace_all(IclTerm newTerm,
                           IclTerm oldTerm)
Replaces all occurences that match with oldTerm by newTerm

Returns:
True if at least one term was actually retracted

db_getRef

public boolean db_getRef(IclTerm inTerm,
                         IclList inParams,
                         IclList references)
Fills the incoming list with all internal references of the terms that unify with the incoming one.

Returns:
Returns false if no solution, true otherwise.
 
 Note : 
   Based on db_Solve 
   Searches the database for matches to term and returns the corresponding 
   unique reference 
 remarks: 
   parameters may include "solution_limit" (integer parameter) 
   returns the answer as an IclTerm, null if fail. 
   db_getRef(my_pred(a,B),[solution_limit(10)])

erase

public boolean erase(IclTerm inRef)
Erases the term that is bound to the incoming reference