prolog.implementation
Class FactList

java.lang.Object
  |
  +--prolog.implementation.FactList
All Implemented Interfaces:
IFact, IFactList

public class FactList
extends java.lang.Object
implements IFactList

FactList is the base implementation for a collection of relations. It can be compared with a database table containing rows of relations. The name of the factlist would be the tablename. That's why factlist extends IFact. So it inherits a name. The relation of the extended IFact are also used for factlists returned by queries. In this relation, parameters of the statements are stored.

prolog:

myFact(joe,dan).

myFact(joe,dan2).

In this example, the two facts "myFact" are stored in a factlist.

interpreter internal:

myFact(joe,dan).

myFact(joe,dan2).

myStatement(X,Y):-myFact(X,Y).

In this example, the results returned by myFact(X,Y) are stored in a factlist.


Field Summary
protected  int colCount
          stores the number of columns stored in this factlist
protected  java.util.List facts
          stores the relations
protected  int name
          stores the name of this fact list
protected  Relation relation
          stores the parameters of this fact list
 
Constructor Summary
FactList(FactList list)
          copy constructor
FactList(int name, int colCount)
          bean constructor
 
Method Summary
 void addAttribute(java.lang.Object value)
          adds a attribute to the relation
 void addRelation(IRelation relation)
          adds a relation to this factlist
 void genXml(java.io.Writer out, ISymbolTable table)
          generates a xml representation of this class
 int getColCount()
           
 IFactList getCopy()
           
 IFactList getMatchings(IFact fact)
          returns a new factlist with facts matching this given fact
 int getName()
          returns the name of this fact
 IRelation getRelation()
          returns the relalation this fact owns
 java.util.Iterator getRelations()
           
 int getRowCount()
           
 void setRelation(IRelation relation)
          sets the relation format of this factlist
 java.lang.String toString()
           
 java.lang.String toString(ISymbolTable table)
          returns a string representation of this oject, if the parameter ISymbolTable is specified, the symbols are decoded
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

relation

protected Relation relation
stores the parameters of this fact list

name

protected int name
stores the name of this fact list

colCount

protected int colCount
stores the number of columns stored in this factlist

facts

protected java.util.List facts
stores the relations
Constructor Detail

FactList

public FactList(int name,
                int colCount)
bean constructor
Parameters:
name - is the name of this factlist

FactList

public FactList(FactList list)
copy constructor
Parameters:
list - to copy
Method Detail

addAttribute

public void addAttribute(java.lang.Object value)
adds a attribute to the relation
Parameters:
value - is the attribute to be added

getName

public int getName()
Description copied from interface: IFact
returns the name of this fact
Specified by:
getName in interface IFact
Returns:
the name of this factlist

getColCount

public int getColCount()
Specified by:
getColCount in interface IFactList
Returns:
the number of columns stored in this factlist

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface IFactList
Returns:
the number of relations in this factlist

setRelation

public void setRelation(IRelation relation)
sets the relation format of this factlist
Specified by:
setRelation in interface IFactList
Parameters:
relation -  

getRelation

public IRelation getRelation()
Description copied from interface: IFact
returns the relalation this fact owns
Specified by:
getRelation in interface IFact
Returns:
the relation of this factlist. in this relation, the variablen names of this factlist are contained

addRelation

public void addRelation(IRelation relation)
adds a relation to this factlist
Specified by:
addRelation in interface IFactList
Following copied from interface: prolog.model.IFactList
Parameters:
atoms - to be added

getRelations

public java.util.Iterator getRelations()
Specified by:
getRelations in interface IFactList
Returns:
a iterator over all relations contained in this class

toString

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

toString

public java.lang.String toString(ISymbolTable table)
Description copied from interface: IFact
returns a string representation of this oject, if the parameter ISymbolTable is specified, the symbols are decoded
Specified by:
toString in interface IFact
Parameters:
table - is the ISymbolTable required to decode the symbols
Returns:
a string representation of this class with decoded symbols

genXml

public void genXml(java.io.Writer out,
                   ISymbolTable table)
            throws java.io.IOException
generates a xml representation of this class
Specified by:
genXml in interface IFact
Parameters:
out - the writer to append the xml
table - is the ISymbolTable to decode the symbols
Throws:
java.io.IOException -  

getCopy

public IFactList getCopy()
Specified by:
getCopy in interface IFactList
Returns:
a copy of this class

getMatchings

public IFactList getMatchings(IFact fact)
                       throws ParameterMatchingError
returns a new factlist with facts matching this given fact
Specified by:
getMatchings in interface IFactList
Parameters:
fact - is the fact to search for
Returns: