prolog.implementation
Class FactDb

java.lang.Object
  |
  +--prolog.implementation.FactDb
All Implemented Interfaces:
IFactDb

public class FactDb
extends java.lang.Object
implements IFactDb

the fact database stores all data found in the prolog program. it stores all facts in factlists that are sorted by their name, so it gets a database representation with a table for every fact type found.


Field Summary
protected  java.util.Map factCollections
          the map storing all factlists under their name
protected  java.util.List listeners
          list of listeners to be informed about changes
 
Constructor Summary
FactDb()
          constructor
 
Method Summary
 void add(IFact f)
          adds a fact to this database. this fact is stored in the factlist having the same name with the fact itself.
 void add(IFactList l)
          adds a factlist to the database
 void add(IRelation relation, int name)
          adds a relation into the factlist with the specified name
 void addListener(IFactDbListener l)
          adds a fact db listener
 void clear()
          clears the whole fact database
protected  void fireFactListAdded(IFactList l)
          fires a fact list added notification
protected  void fireModelChanged()
          fires a model changed notification
protected  void fireRelationAdded(IRelation l, int name)
          fires a fact added notification
 void genXml(java.io.Writer out, ISymbolTable table)
          generates xml representing this object
 IFactList getFactList(int key)
          returns the factlist with the specified name
 java.util.Iterator getFactLists()
          returns a iterator over all facts stored in this factlist
 boolean isFact(IFact f)
          returns true if the given fact can be found in the database
 void removeListener(IFactDbListener l)
          removes a fact db listener
 java.lang.String toString()
          returns a string representation of this class
 java.lang.String toString(ISymbolTable table)
          returns a string representation of this class with decoded symbols
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

listeners

protected java.util.List listeners
list of listeners to be informed about changes

factCollections

protected java.util.Map factCollections
the map storing all factlists under their name
Constructor Detail

FactDb

public FactDb()
constructor
Method Detail

clear

public void clear()
clears the whole fact database
Specified by:
clear in interface IFactDb

add

public void add(IFact f)
adds a fact to this database. this fact is stored in the factlist having the same name with the fact itself.
Specified by:
add in interface IFactDb
Following copied from interface: prolog.model.IFactDb
Parameters:
f - is the fact to be added

add

public void add(IRelation relation,
                int name)
adds a relation into the factlist with the specified name
Specified by:
add in interface IFactDb
Parameters:
relation - - the relation to be added
name - - the name of the relation

add

public void add(IFactList l)
adds a factlist to the database

getFactList

public IFactList getFactList(int key)
returns the factlist with the specified name
Specified by:
getFactList in interface IFactDb
Parameters:
key - - the name of the factlist
Returns:
- the found factlist or null if no one was found

getFactLists

public java.util.Iterator getFactLists()
returns a iterator over all facts stored in this factlist
Specified by:
getFactLists in interface IFactDb
Following copied from interface: prolog.model.IFactDb
Returns:
a iterator over all stored factlists

isFact

public boolean isFact(IFact f)
               throws ParameterMatchingError
returns true if the given fact can be found in the database
Specified by:
isFact in interface IFactDb
Returns:
true if fact was found

toString

public java.lang.String toString()
returns a string representation of this class
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(ISymbolTable table)
returns a string representation of this class with decoded symbols
Specified by:
toString in interface IFactDb
Following copied from interface: prolog.model.IFactDb
Parameters:
table - is the symboltable to decode
Returns:
a string representation ;-)

genXml

public void genXml(java.io.Writer out,
                   ISymbolTable table)
            throws java.io.IOException
generates xml representing this object
Specified by:
genXml in interface IFactDb
Parameters:
out -  
table -  
Throws:
java.io.IOException -  

addListener

public void addListener(IFactDbListener l)
adds a fact db listener

removeListener

public void removeListener(IFactDbListener l)
removes a fact db listener

fireModelChanged

protected void fireModelChanged()
fires a model changed notification

fireFactListAdded

protected void fireFactListAdded(IFactList l)
fires a fact list added notification

fireRelationAdded

protected void fireRelationAdded(IRelation l,
                                 int name)
fires a fact added notification