standup.unify
Class Bindings

java.lang.Object
  extended by standup.unify.Bindings

public class Bindings
extends Object

Stores the results of a unification.

Provides dereference(Unifiable), a method of obtaining the result of a unification.

Author:
Ruli Manurung

Field Summary
(package private)  Hashtable<UnifiableVariable,Unifiable> bindings
           
static int FAIL
           
private  boolean failure
           
 
Constructor Summary
Bindings()
           
Bindings(Hashtable<UnifiableVariable,Unifiable> BB)
           
Bindings(int x)
           
 
Method Summary
 Bindings copy()
           
 Unifiable dereference(Unifiable old)
          Returns the result of unification by applying the values in this bindings to the given Unifiable.
private  UnifiableCompound dereference(UnifiableCompound old)
           
private  UnifiableList dereference(UnifiableList old)
           
private  Unifiable dereference(UnifiableVariable W)
           
 void destructivelyUpdate(Bindings newB)
          Updates the current bindings hashtable with the one in the given Bindings.
(package private)  Unifiable get(UnifiableVariable key)
           
 boolean isFailure()
           
(package private)  void put(UnifiableVariable Key, Unifiable Value)
           
 boolean replace(UnifiableVariable variable, Unifiable oldValue, Unifiable newValue)
          Replaces all bindings to oldValue with bindings to newValue.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FAIL

public static final int FAIL
See Also:
Constant Field Values

bindings

Hashtable<UnifiableVariable,Unifiable> bindings

failure

private boolean failure
Constructor Detail

Bindings

public Bindings()

Bindings

public Bindings(int x)

Bindings

public Bindings(Hashtable<UnifiableVariable,Unifiable> BB)
Method Detail

destructivelyUpdate

public void destructivelyUpdate(Bindings newB)
Updates the current bindings hashtable with the one in the given Bindings. Use with caution!

Parameters:
newB -

replace

public boolean replace(UnifiableVariable variable,
                       Unifiable oldValue,
                       Unifiable newValue)
Replaces all bindings to oldValue with bindings to newValue. This is rather untypical unification operation, but is required for the 'lexlinks' in joke graph building. It should only be called to replace Lexemes and WordForms to {code standup.joke.JokeGraphNode}s...

Parameters:
oldValue -
newValue -
Returns:
true if successfully replaced the values, false otherwise

isFailure

public boolean isFailure()

get

Unifiable get(UnifiableVariable key)

put

void put(UnifiableVariable Key,
         Unifiable Value)

copy

public Bindings copy()

toString

public String toString()
Overrides:
toString in class Object

dereference

public Unifiable dereference(Unifiable old)
Returns the result of unification by applying the values in this bindings to the given Unifiable. Returns a new instance -- it does not affect the given value.

Parameters:
old -
Returns:

dereference

private UnifiableCompound dereference(UnifiableCompound old)

dereference

private UnifiableList dereference(UnifiableList old)

dereference

private Unifiable dereference(UnifiableVariable W)