com.bigdata.bop
Interface IBindingSet

All Superinterfaces:
Cloneable, Serializable
All Known Implementing Classes:
ContextBindingSet, EmptyBindingSet, HashBindingSet, ListBindingSet

public interface IBindingSet
extends Cloneable, Serializable

Interface for a set of bindings. The set of variables values is extensible and the bound values are loosely typed.

Version:
$Id: IBindingSet.java 5580 2011-11-09 12:52:10Z thompsonbry $
Author:
Bryan Thompson

Method Summary
 void clear(IVariable var)
          Clear any binding for the variable.
 void clearAll()
          Clear all bindings.
 IBindingSet clone()
          Return a shallow copy of the binding set.
 IBindingSet copy(IVariable[] variablesToKeep)
          Return a shallow copy of the binding set, eliminating unnecessary variables.
 boolean equals(Object o)
          True iff the variables and their bound values are the same for the two binding sets.
 IConstant get(IVariable var)
          Return the binding for the variable.
 int hashCode()
          The hash code of a binding is defined as the bit-wise XOR of the hash codes of the IConstants for its bound variables.
 boolean isBound(IVariable var)
          Return true iff the variable is bound.
 boolean isEmpty()
          true iff there are no variable bindings in the binding set.
 Iterator<Map.Entry<IVariable,IConstant>> iterator()
          Visits the bindings.
 void set(IVariable var, IConstant val)
          Bind the variable to the value.
 int size()
          The #of bound variables.
 Iterator<IVariable> vars()
          Visits the bound variables.
 

Method Detail

isBound

boolean isBound(IVariable var)
Return true iff the variable is bound.

Parameters:
var - The variable.
Returns:
true if the variable is bound.
Throws:
IllegalArgumentException - if var is null.

set

void set(IVariable var,
         IConstant val)
Bind the variable to the value.

Parameters:
var - The variable.
val - The value (MAY NOT be null).
Throws:
IllegalArgumentException - if var is null.
IllegalArgumentException - if val is null.

get

IConstant get(IVariable var)
Return the binding for the variable.

Parameters:
var - The variable.
Returns:
the binding for the variable -or- null iff the variable is not bound.
Throws:
IllegalArgumentException - if var is null.

clear

void clear(IVariable var)
Clear any binding for the variable.

Parameters:
var - The variable.
Throws:
IllegalArgumentException - if var is null.

clearAll

void clearAll()
Clear all bindings.


isEmpty

boolean isEmpty()
true iff there are no variable bindings in the binding set.


size

int size()
The #of bound variables.


iterator

Iterator<Map.Entry<IVariable,IConstant>> iterator()
Visits the bindings.


vars

Iterator<IVariable> vars()
Visits the bound variables.

TODO:
The unit tests verify that the implementations do not permit mutation using the iterator, but that is not actually specified by the API as forbidden.

clone

IBindingSet clone()
Return a shallow copy of the binding set.


copy

IBindingSet copy(IVariable[] variablesToKeep)
Return a shallow copy of the binding set, eliminating unnecessary variables.

Parameters:
variablesToKeep - When non-null, only the listed variables are retained.

equals

boolean equals(Object o)
True iff the variables and their bound values are the same for the two binding sets.

Overrides:
equals in class Object
Parameters:
o - Another binding set.

hashCode

int hashCode()
The hash code of a binding is defined as the bit-wise XOR of the hash codes of the IConstants for its bound variables. Unbound variables are ignored when computing the hash code. Binding sets are unordered collections, therefore the calculated hash code intentionally does not depend on the order in which the bindings are visited. The hash code reflects the current state of the bindings and must be recomputed if the bindings are changed.

Overrides:
hashCode in class Object


Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.