JACK 5.4 Application Interface

aos.jack.jak.logic
Class Variable

java.lang.Object
  extended byaos.jack.jak.logic.Unifiable
      extended byaos.jack.jak.logic.Variable
Direct Known Subclasses:
BooleanVariable, ByteVariable, CharacterVariable, DoubleVariable, FloatVariable, IntegerVariable, LongVariable, ObjectVariable, ShortVariable, StringVariable

public class Variable
extends Unifiable

This is the superclass of all objects generated by the JACK compiler to represent variables declared as type "logical". It provides different methods to access the value of the variable depending on the specific variable type. For example, as_int(), as_string(), etc.

Attempting to access the value of a variable using an accessor of the wrong type will have undefined results.

As of JACK version 5.2, the preferred way to access a logical variable's value is to use the getValue() method provided by the derived class.


Constructor Summary
protected Variable(LogicEnv e, java.lang.Class t, boolean b)
           
 
Method Summary
 boolean as_boolean()
          Return the value of this variable as a boolean.
 byte as_byte()
          Return the value of this variable as a byte.
 char as_char()
          Return the value of this variable as a char.
 double as_double()
          Return the value of this variable as a double.
 float as_float()
          Return the value of this variable as a float.
 int as_int()
          Return the value of this variable as a int.
 long as_long()
          Return the value of this variable as a long.
 java.lang.Object as_object()
          Return the value of this variable as a Object.
 short as_short()
          Return the value of this variable as a short.
 java.lang.String as_string()
          Return the value of this variable as a String.
 LogicEnv getEnv()
          Return the logic environment in which this variable resides.
 java.lang.Class getType()
          The type of entity this represents (for example, java.lang.Long).
 Unifiable getValueOf(LogicEnv e)
          Return the value of this variable in the given logical environment.
 boolean isBound()
          Returns whether the variable is currently bound.
 boolean isGround()
          Returns whether the variable is currently grounded.
 java.lang.String toString()
          Return the value of this variable as a String.
protected  void unbind()
           
 boolean unify(boolean v)
           
 boolean unify(byte v)
           
 boolean unify(char v)
           
 boolean unify(double v)
           
 boolean unify(float v)
           
 boolean unify(int v)
           
 boolean unify(long v)
           
 boolean unify(java.lang.Object v)
           
 boolean unify(short v)
           
 boolean unify(Unifiable v)
          Unify this variable with anything implementing the Unifiable interface.
 boolean unify(Variable v)
          Unify this variable with another variable.
 void untrail()
           
static java.lang.String variableType(java.lang.String key)
           
 
Methods inherited from class aos.jack.jak.logic.Unifiable
as_unifiable, logicException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Variable

protected Variable(LogicEnv e,
                   java.lang.Class t,
                   boolean b)
Method Detail

variableType

public static java.lang.String variableType(java.lang.String key)

getEnv

public LogicEnv getEnv()
Return the logic environment in which this variable resides.


unbind

protected void unbind()

untrail

public void untrail()

isBound

public boolean isBound()
Returns whether the variable is currently bound.


isGround

public boolean isGround()
Returns whether the variable is currently grounded. Note: a variable can be bound but not grounded if it is bound to an ungrounded variable.


getType

public java.lang.Class getType()
Description copied from class: Unifiable
The type of entity this represents (for example, java.lang.Long).

Overrides:
getType in class Unifiable

unify

public boolean unify(Variable v)
Unify this variable with another variable.

Overrides:
unify in class Unifiable

unify

public boolean unify(Unifiable v)
Unify this variable with anything implementing the Unifiable interface. If this variable is currently bound, then the bound value is attempted to be unified with the given Unifiable.

Overrides:
unify in class Unifiable

unify

public boolean unify(boolean v)
Overrides:
unify in class Unifiable

unify

public boolean unify(byte v)
Overrides:
unify in class Unifiable

unify

public boolean unify(char v)
Overrides:
unify in class Unifiable

unify

public boolean unify(short v)
Overrides:
unify in class Unifiable

unify

public boolean unify(int v)
Overrides:
unify in class Unifiable

unify

public boolean unify(long v)
Overrides:
unify in class Unifiable

unify

public boolean unify(float v)
Overrides:
unify in class Unifiable

unify

public boolean unify(double v)
Overrides:
unify in class Unifiable

unify

public boolean unify(java.lang.Object v)
Overrides:
unify in class Unifiable

as_boolean

public boolean as_boolean()
Return the value of this variable as a boolean. If unbound, generates an error.

Overrides:
as_boolean in class Unifiable

as_char

public char as_char()
Return the value of this variable as a char. If unbound, generates an error.

Overrides:
as_char in class Unifiable

as_byte

public byte as_byte()
Return the value of this variable as a byte. If unbound, generates an error.

Overrides:
as_byte in class Unifiable

as_short

public short as_short()
Return the value of this variable as a short. If unbound, generates an error.

Overrides:
as_short in class Unifiable

as_int

public int as_int()
Return the value of this variable as a int. If unbound, generates an error.

Overrides:
as_int in class Unifiable

as_long

public long as_long()
Return the value of this variable as a long. If unbound, generates an error.

Overrides:
as_long in class Unifiable

as_float

public float as_float()
Return the value of this variable as a float.

Overrides:
as_float in class Unifiable

as_double

public double as_double()
Return the value of this variable as a double.

Overrides:
as_double in class Unifiable

as_object

public java.lang.Object as_object()
Return the value of this variable as a Object. If unbound, generates an error.

Overrides:
as_object in class Unifiable

toString

public java.lang.String toString()
Return the value of this variable as a String. If unbound, this generates an error. This gets traced if kernel debugging of bindings is turned on.


as_string

public java.lang.String as_string()
Return the value of this variable as a String. If unbound, this generates an error. This does NOT get traced if kernel debugging of bindings is on.

Overrides:
as_string in class Unifiable

getValueOf

public Unifiable getValueOf(LogicEnv e)
Return the value of this variable in the given logical environment.


JACK 5.4 Application Interface

Copyright (C) 1999-2008, Agent Oriented Software Pty. Ltd.

US Government Restricted Rights
The JACK Modules and relevant Software Material have been developed entirely at private expense and are accordingly provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of DFARS 252.227-7013 or subparagraph (c)(1) and (2) of the Commercial Computer Software Restricted Rights and 48 CFR 52.2270-19, as applicable.


Agent Oriented Software Pty. Ltd.     http://www.aosgrp.com
PO Box 639, Carlton South, Victoria 3053, Australia
Phone: +61 3 9349 5055, Fax: +61 3 9349 5088