prolog.implementation
Class StatementMap

java.lang.Object
  |
  +--prolog.implementation.StatementMap
All Implemented Interfaces:
IStatementMap

public class StatementMap
extends java.lang.Object
implements IStatementMap

The statementmap stores statements under their name. It is a collection with statements but for faster access from the interpreter, they are stored in a map to prevent iterations.


Field Summary
protected  java.util.List listeners
          list of registered listeners
protected  java.util.Map statements
          storing the statements
 
Constructor Summary
StatementMap()
          create a satementmap
 
Method Summary
 void addListener(IStatementMapListener l)
          registers a listener
 void addStatement(IStatement statement)
          adds a statement to the statementmap
 void clear()
          clears the statement map
protected  void fireChange()
          fire a content changed notify
 void genXml(java.io.Writer out, ISymbolTable table)
          generates a xml representation with decoded symbols
 IStatement getMatchingStatement(IFact fact)
          returns a statement matching the given fact, if one was found.
 IStatement getStatement(int key)
          returns the statement for the given name
 java.util.Iterator getStatements()
          returns a iterator over all stored statements
 void removeListener(IStatementMapListener l)
          removes a listener
 java.lang.String toString()
          returns a string representation
 java.lang.String toString(ISymbolTable table)
          returns a string representation 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 registered listeners

statements

protected java.util.Map statements
storing the statements
Constructor Detail

StatementMap

public StatementMap()
create a satementmap
Method Detail

clear

public void clear()
clears the statement map
Specified by:
clear in interface IStatementMap

addStatement

public void addStatement(IStatement statement)
adds a statement to the statementmap
Specified by:
addStatement in interface IStatementMap

getStatements

public java.util.Iterator getStatements()
returns a iterator over all stored statements
Specified by:
getStatements in interface IStatementMap

getStatement

public IStatement getStatement(int key)
returns the statement for the given name
Specified by:
getStatement in interface IStatementMap
Parameters:
key - is the name
Returns:
a statement if one was found ;-)

getMatchingStatement

public IStatement getMatchingStatement(IFact fact)
returns a statement matching the given fact, if one was found.
Specified by:
getMatchingStatement in interface IStatementMap

toString

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

toString

public java.lang.String toString(ISymbolTable table)
returns a string representation with decoded symbols
Specified by:
toString in interface IStatementMap
Parameters:
table -  
Returns:
 

genXml

public void genXml(java.io.Writer out,
                   ISymbolTable table)
            throws java.io.IOException
generates a xml representation with decoded symbols
Specified by:
genXml in interface IStatementMap
Parameters:
out -  
table -  
Throws:
java.io.IOException -  

addListener

public void addListener(IStatementMapListener l)
registers a listener

removeListener

public void removeListener(IStatementMapListener l)
removes a listener

fireChange

protected void fireChange()
fire a content changed notify