prolog.implementation
Class AbstractStatement

java.lang.Object
  |
  +--prolog.implementation.Fact
        |
        +--prolog.implementation.AbstractStatement
All Implemented Interfaces:
IFact, IStatement
Direct Known Subclasses:
ConstraintStatement, NodeStatement

public abstract class AbstractStatement
extends Fact
implements IStatement

AbstractStatement has methods for reordering a relation after a given format


Fields inherited from class prolog.implementation.Fact
name, relation
 
Constructor Summary
AbstractStatement(int name)
          constructor 1
AbstractStatement(int name, IRelation r)
          constructor 2
 
Method Summary
protected  Fact generateFact(IFact f, java.util.Map factFormat, IStatement targetStatement)
          generates a new fact matching the format of the given statement
protected  Relation generateRelation(IFact f, java.util.Map factFormat, IStatement targetStatement)
          builds a new relation from the given fact matching the format of the targetStatement. create new relation iterate over atoms of relation of statement2 search for atom value int factmap and get index in fact f fetch atom from fact f at index and add atom found to new relation
 
Methods inherited from class prolog.implementation.Fact
addAttribute, genXml, getName, getRelation, toString, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 
Methods inherited from interface prolog.model.IStatement
query
 
Methods inherited from interface prolog.model.IFact
genXml, getName, getRelation, toString
 

Constructor Detail

AbstractStatement

public AbstractStatement(int name)
constructor 1

AbstractStatement

public AbstractStatement(int name,
                         IRelation r)
constructor 2
Method Detail

generateFact

protected Fact generateFact(IFact f,
                            java.util.Map factFormat,
                            IStatement targetStatement)
                     throws ParameterMatchingError
generates a new fact matching the format of the given statement
Parameters:
f - - the fact to be taken the values from
srcRelationFormat - - the format of the given fact
targetStatement - - the statement for which the new fact is created for
Returns:
a new fact formated for the targetStatement

generateRelation

protected Relation generateRelation(IFact f,
                                    java.util.Map factFormat,
                                    IStatement targetStatement)
                             throws ParameterMatchingError

builds a new relation from the given fact matching the format of the targetStatement.

create new relation

iterate over atoms of relation of statement2

search for atom value int factmap and get index in fact f

fetch atom from fact f at index and add atom found to new relation

Parameters:
f - = ?-statement1(batman,robin).
factFormat - = [X]=[0],[Y]=[1]
targetStatement - statement1(X,Y):-statement2(Y,X).
Returns:
(robin,batman)