prolog.implementation
Class AndStatement

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

public class AndStatement
extends NodeStatement

The AndStatement represents the and operation over two tables.


Inner Class Summary
protected  class AndStatement.CacheMap
          this class is the implementation of a cache map
 
Fields inherited from class prolog.implementation.NodeStatement
childs
 
Fields inherited from class prolog.implementation.Fact
name, relation
 
Constructor Summary
AndStatement(IFact f)
          constructor 2
AndStatement(int name)
          constructor 1
 
Method Summary
protected  boolean addMatching(AndStatement.CacheMap m, java.lang.Object key, java.lang.Object mapping)
          checks wether the key is allready stored in the cachmap. if not, the value is stored and true is returned. if yes, it was stored, the stored value is compared with the given mapping. then the result of the comparation is returned
protected  void findMatching(IFact f, java.util.List all, int index, IFactList finalResults, AndStatement.CacheMap cachMap)
          finds all matchings in the list with results collected by query and puts it in targetformat into the finalresult factlist
 IFactList query(IFact f, IFactDb l, IStatementMap constraints)
          queries the child nodes and calls the recursive findMatching method to merge all results.
 java.lang.String toString()
           
 java.lang.String toString(ISymbolTable table)
          returns a string representation of this class with decoded symbols
 
Methods inherited from class prolog.implementation.NodeStatement
addStatement, genXml
 
Methods inherited from class prolog.implementation.AbstractStatement
generateFact, generateRelation
 
Methods inherited from class prolog.implementation.Fact
addAttribute, getName, getRelation
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 
Methods inherited from interface prolog.model.IFact
getName, getRelation
 

Constructor Detail

AndStatement

public AndStatement(int name)
constructor 1

AndStatement

public AndStatement(IFact f)
constructor 2
Method Detail

query

public IFactList query(IFact f,
                       IFactDb l,
                       IStatementMap constraints)
                throws ParameterMatchingError
queries the child nodes and calls the recursive findMatching method to merge all results.
Parameters:
f - - the target format
l - - the fact database
constraints - - the statements to resolve when not found in fdb
Returns:
a result factlist with all matching results in the format described in the f parameter fact
Throws:
ParameterMatchingError -  

findMatching

protected void findMatching(IFact f,
                            java.util.List all,
                            int index,
                            IFactList finalResults,
                            AndStatement.CacheMap cachMap)
                     throws java.lang.Exception
finds all matchings in the list with results collected by query and puts it in targetformat into the finalresult factlist
Parameters:
f - - the target format
all - - the list with matchings returned by the childs
index - - the index of the current factlist, begins with 0
finalResults - - the collector for really matching final results
cachMap - - the cachemap used to find matching values
Returns:
 
Throws:
java.lang.Exception -  

addMatching

protected boolean addMatching(AndStatement.CacheMap m,
                              java.lang.Object key,
                              java.lang.Object mapping)
checks wether the key is allready stored in the cachmap. if not, the value is stored and true is returned. if yes, it was stored, the stored value is compared with the given mapping. then the result of the comparation is returned
Parameters:
m - - the cachemap where to add the matching
key - - the key under which the value should be stored
mapping - - the value to be stored
Returns:
true if the given key and mapping does not produce any conflicts, else false

toString

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

toString

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