prolog.model
Interface IRelation

All Known Implementing Classes:
Relation

public interface IRelation

The base interface of a relation between some atoms, like a row in a database. This interface is used to store and get facts but also to store and get parameters e.g. in a statement

prolog: myFact(joe,dan).

in this example, the relation would contain the atoms "joe" and "dan"


Method Summary
 java.util.Map buildMap()
          builds a indexmap. a indexmap contains the atom as key and the index as integer. this function is only used for parameter matching.
 void genXml(java.io.Writer out, ISymbolTable table)
          generates xml describing this relation
 IAtom get(int index)
          returns the atom at the specified index
 int getValueCount()
          returns the number of atoms contained in this relation
 java.util.Iterator getValues()
          returns an iterator over all atoms contained in this relation
 java.lang.String toString(int[] parameterNames, ISymbolTable table)
          returns a string representation of this object with decoded symbols in prolog syntax used for query results e.g.
 java.lang.String toString(ISymbolTable table)
          returns a string representation of this object with decoded symbols
 

Method Detail

getValueCount

public int getValueCount()
returns the number of atoms contained in this relation
Returns:
number of atoms

get

public IAtom get(int index)
returns the atom at the specified index
Parameters:
index - of the atom to be returned
Returns:
atom at the specified index

getValues

public java.util.Iterator getValues()
returns an iterator over all atoms contained in this relation
Returns:
iterator over the values in this relation

buildMap

public java.util.Map buildMap()
builds a indexmap. a indexmap contains the atom as key and the index as integer. this function is only used for parameter matching.
Returns:
the created indexmap

genXml

public void genXml(java.io.Writer out,
                   ISymbolTable table)
            throws java.io.IOException
generates xml describing this relation
Parameters:
out - the writer where o append the xml
table - the symboltable if the xml should be decoded
Throws:
java.io.IOException - if writing xml fails

toString

public java.lang.String toString(ISymbolTable table)
returns a string representation of this object with decoded symbols
Parameters:
table - - the symboltable used to decode
Returns:
the string representation

toString

public java.lang.String toString(int[] parameterNames,
                                 ISymbolTable table)
returns a string representation of this object with decoded symbols in prolog syntax used for query results e.g. X=a, Y=b
Parameters:
table - - the symboltable used to decode
parameterNames - - the names of the parameters in this relation
Returns:
the string representation