se.sics.prologbeans
Class Bindings

java.lang.Object
  extended by se.sics.prologbeans.Bindings
Direct Known Subclasses:
QueryAnswer

public class Bindings
extends java.lang.Object

Bindings handles the variable bindings in the communication with the prolog server. Using variable bindings ensures that the values are properly quoted when sent to the prolog server.


Constructor Summary
Bindings()
          Creates a new Bindings instance with no variable bindings.
Bindings(Bindings binds)
          Creates a new Bindings instance and copies all existing variable bindings from the specified bindings.
 
Method Summary
 Bindings bind(java.lang.String name, double doublevalue)
          Adds the specified variable binding.
 Bindings bind(java.lang.String name, float floatvalue)
          Adds the specified variable binding.
 Bindings bind(java.lang.String name, int intvalue)
          Adds the specified variable binding.
 Bindings bind(java.lang.String name, long longvalue)
          Adds the specified variable binding.
 Bindings bind(java.lang.String name, PBTerm termvalue)
          Adds the specified variable binding.
 Bindings bind(java.lang.String name, java.lang.String stringvalue)
          Adds the specified variable binding.
 Bindings bindAtom(java.lang.String name, java.lang.String atomvalue)
          Adds the specified variable binding.
 PBTerm getValue(java.lang.String name)
          Returns the value for the specified variable or null if the variable is not bound.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bindings

public Bindings()
Creates a new Bindings instance with no variable bindings.


Bindings

public Bindings(Bindings binds)
Creates a new Bindings instance and copies all existing variable bindings from the specified bindings.

Parameters:
binds - the variable bindings to copy
Method Detail

bind

public Bindings bind(java.lang.String name,
                     int intvalue)
Adds the specified variable binding. The variable name must start with an upper case letter or '_'.

Parameters:
name - a prolog variable name
intvalue - the value to bind to the variable
Returns:
a reference to this Bindings object
Throws:
{@if.java - java.lang. }IllegalArgumentException if the name is not a valid prolog variable name

bind

public Bindings bind(java.lang.String name,
                     long longvalue)
Adds the specified variable binding. The variable name must start with an upper case letter or '_'.

Parameters:
name - a prolog variable name
longvalue - the value to bind to the variable
Returns:
a reference to this Bindings object
Throws:
{@if.java - java.lang. }IllegalArgumentException if the name is not a valid prolog variable name

bind

public Bindings bind(java.lang.String name,
                     float floatvalue)
Adds the specified variable binding. The variable name must start with an upper case letter or '_'.

Parameters:
name - a prolog variable name
floatvalue - the value to bind to the variable
Returns:
a reference to this Bindings object
Throws:
{@if.java - java.lang. }IllegalArgumentException if the name is not a valid prolog variable name

bind

public Bindings bind(java.lang.String name,
                     double doublevalue)
Adds the specified variable binding. The variable name must start with an upper case letter or '_'.

Parameters:
name - a prolog variable name
doublevalue - the value to bind to the variable
Returns:
a reference to this Bindings object
Throws:
{@if.java - java.lang. }IllegalArgumentException if the name is not a valid prolog variable name

bind

public Bindings bind(java.lang.String name,
                     java.lang.String stringvalue)
Adds the specified variable binding. The variable name must start with an upper case letter or '_'.

Parameters:
name - a prolog variable name
stringvalue - the value to bind to the variable
Returns:
a reference to this Bindings object
Throws:
{@if.java - java.lang. }IllegalArgumentException if the name is not a valid prolog variable name

bind

public Bindings bind(java.lang.String name,
                     PBTerm termvalue)
Adds the specified variable binding. The variable name must start with an upper case letter or '_'.

Parameters:
name - a prolog variable name
termvalue - the value to bind to the variable
Returns:
a reference to this Bindings object
Throws:
{@if.java - java.lang. }IllegalArgumentException if the name is not a valid prolog variable name

bindAtom

public Bindings bindAtom(java.lang.String name,
                         java.lang.String atomvalue)
Adds the specified variable binding. The variable name must start with an upper case letter or '_'. The value will be bound as an atom.

Parameters:
name - a prolog variable name
atomvalue - the value to bind to the variable as an atom
Returns:
a reference to this Bindings object
Throws:
{@if.java - java.lang. }IllegalArgumentException if the name is not a valid prolog variable name

getValue

public PBTerm getValue(java.lang.String name)
Returns the value for the specified variable or null if the variable is not bound.

Parameters:
name - the name of the variable
Returns:
the value of the variable as a PBTerm or null if the variable is not bound

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object