GNU Prolog for Java

gnu.prolog.database
Class Module

java.lang.Object
  extended by gnu.prolog.database.Module

public class Module
extends Object

Module in database

Author:
Contantine A Plotnikov

Field Summary
protected  List<Pair<PrologTextLoaderError,Term>> initialization
          initialization
protected  List<PredicateListener> predicateListeners
           
protected  Map<CompoundTermTag,Predicate> tag2predicate
          map from tag to predicates
 
Constructor Summary
Module()
           
 
Method Summary
 void addInitialization(PrologTextLoaderError prologTextLoaderError, Term term)
          add term to initialization list
 void addPredicateListener(PredicateListener listener)
           
 void clearInitialization()
          Intended to be run from Environment.runInitialization(Interpreter) and from nowhere else.
 Predicate createDefinedPredicate(CompoundTermTag tag)
          create new predicate defined in this module
 Predicate getDefinedPredicate(CompoundTermTag tag)
          get predicate defined in this module
 List<Pair<PrologTextLoaderError,Term>> getInitialization()
          get initaliztion
 Set<CompoundTermTag> getPredicateTags()
          get predicate tags
 void predicateUpdated(CompoundTermTag tag)
           
 void removeDefinedPredicate(CompoundTermTag tag)
           
 void removePredicateListener(PredicateListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tag2predicate

protected Map<CompoundTermTag,Predicate> tag2predicate
map from tag to predicates


initialization

protected List<Pair<PrologTextLoaderError,Term>> initialization
initialization


predicateListeners

protected List<PredicateListener> predicateListeners
Constructor Detail

Module

public Module()
Method Detail

createDefinedPredicate

public Predicate createDefinedPredicate(CompoundTermTag tag)
create new predicate defined in this module

Parameters:
tag - tag of this predicate
Returns:
created predicate
Throws:
IllegalStateException - when predicate already exists

getDefinedPredicate

public Predicate getDefinedPredicate(CompoundTermTag tag)
get predicate defined in this module

Parameters:
tag - tag of this predicate
Returns:
predicate defined in this module or null if predicate is not found

removeDefinedPredicate

public void removeDefinedPredicate(CompoundTermTag tag)

addInitialization

public void addInitialization(PrologTextLoaderError prologTextLoaderError,
                              Term term)
add term to initialization list

Parameters:
prologTextLoaderError - the partial error to be used if this term throws an error
term - the goal to execute at initialization

getInitialization

public List<Pair<PrologTextLoaderError,Term>> getInitialization()
get initaliztion

Returns:
the list of the goals with their corresponding partial PrologTextLoaderErrors to be used if they throw an error.

clearInitialization

public void clearInitialization()
Intended to be run from Environment.runInitialization(Interpreter) and from nowhere else. Resets the initialization list to the empty list so that they can be iterated through again later. Should be called in a synchronized block which read out the initiaization list using getInitialization()


getPredicateTags

public Set<CompoundTermTag> getPredicateTags()
get predicate tags

Returns:
the set of tags for Predicates.

predicateUpdated

public void predicateUpdated(CompoundTermTag tag)

addPredicateListener

public void addPredicateListener(PredicateListener listener)

removePredicateListener

public void removePredicateListener(PredicateListener listener)

GNU Prolog for Java