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 value)
          Adds the specified variable binding.
 Bindings bind(java.lang.String name, float value)
          Adds the specified variable binding.
 Bindings bind(java.lang.String name, int value)
          Adds the specified variable binding.
 Bindings bind(java.lang.String name, long value)
          Adds the specified variable binding.
 Bindings bind(java.lang.String name, java.lang.String value)
          Adds the specified variable binding.
 Bindings bind(java.lang.String name, Term value)
          Adds the specified variable binding.
 Bindings bindAtom(java.lang.String name, java.lang.String value)
          Adds the specified variable binding.
 Term 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 value)
Adds the specified variable binding. The variable name must start with an upper case letter or '_'.

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

bind

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

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

bind

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

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

bind

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

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

bind

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

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

bind

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

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

bindAtom

public Bindings bindAtom(java.lang.String name,
                         java.lang.String value)
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
value - the value to bind to the variable as an atom
Returns:
a reference to this Bindings object
Throws:
java.lang.IllegalArgumentException - if the name is not a valid prolog variable name

getValue

public Term 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 Term or null if the variable is not bound

toString

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