Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

alice.tuprolog
Class Term  view Term download Term.java

java.lang.Object
  extended byalice.tuprolog.Term
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
NullTerm, Struct, Var

public class Term
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

root class for prolog data term.

the design follows the Facade Pattern: this class provide the interface for some basic services which are significant only for specific derived classes

this is useful because of the derived class are few and well known: Struct and Var. (in this way boring casting is avoid)

direct instances of class Term represent numbers (floats and integers)


Field Summary
private  double doubleValue
           
static Struct FALSE
           
(package private) static int FLOAT
           
protected  int id
           
(package private) static int INT
           
private  long longValue
           
(package private) static int NULL
           
(package private) static int OBJECT
           
(package private) static int STRUCT
           
static Struct TRUE
           
private  java.lang.Object value
           
(package private) static int VAR
           
 
Constructor Summary
protected Term()
           
  Term(double v)
          constructs a real prolog term using a double.
  Term(float v)
          constructs a real prolog term using a float.
  Term(int v)
          constructs an integer prolog term using an int.
  Term(long v)
          constructs an integer prolog term using a long.
  Term(java.lang.Object t)
          constructs a term incapsulating a java object.
 
Method Summary
 java.lang.Object clone()
          cloning the term.
 Term copy(alice.util.LinkedList vl)
          gets a copy (with renamed variables) of the term.
 void free(int m)
          significant for Var terms.
 double getDouble()
          gets term double value.
 float getFloat()
          gets term float value.
 int getInt()
          gets term int value.
static java.util.Iterator getIterator(java.lang.String text)
          gets an iterator that provides a term stream from a source text.
 long getLong()
          gets term long value.
 java.lang.String getName()
          significant only for Var and Struct derived class.
 java.lang.Object getObject()
          gets term object value
 java.lang.Object getObject(int index)
          significant only for Struct derived class.
 java.lang.String getString(int index)
          significant only for Struct derived class.
 Struct getStruct(int index)
          significant only for Struct derived class.
 Struct getStruct(java.lang.String name)
          significant only for Struct derived class.
 Term getTerm()
          gets the actual term of the object.
 Term getTerm(int index)
          significant only for Struct derived class.
 Term getVar(java.lang.String name)
          significant only for Struct derived class.
 boolean isAny()
          is it a prolog any(_) variable?
 boolean isAtom()
          is it a prolog (alphanumeric) atom?
 boolean isClause()
          is it a prolog clause?
 boolean isCompound()
          is it a prolog compound term?
 boolean isConst()
          is it a constant prolog term?
 boolean isEmptyList()
          is it a prolog empty list?
 boolean isEQU(Term t)
          is term equal to term t?
 boolean isFalse()
          is it a prolog false atom?
 boolean isFloat()
          is it a prolog float term?
 boolean isGround()
          is it a ground term?
 boolean isGT(Term t)
          is term greater than term t?
 boolean isInt()
          is it a prolog integer term?
 boolean isList()
          is it a prolog list?
 boolean isNum()
          is it a prolog numeric term?
 boolean isObject()
          is it a prolog incapsulating a java object?
 boolean isStruct()
          is it a struct
 boolean isTrue()
          is it a prolog true atom?
 boolean isVar()
          is it a prolog variable?
 boolean match(Term t)
          matching without unification; only true or false, without bindings.
static Term parse(java.lang.String st)
          parse a Term from a string.
(package private) static Term parse(java.lang.String st, OperatorManager op)
          parse a Term from a string.
(package private) static Term parseSentence(java.lang.String st, OperatorManager op)
           
 int renameVars(int count)
          renaming variables of the term starting from specified count.
(package private)  int renameVars(alice.util.LinkedList vars, int count)
           
 java.lang.String toRawString()
          significant only for Struct derived class; for real Term it's like toString
 java.lang.String toString()
          stringizing the term without taking in consideration operators.
 java.lang.String toString(OperatorManager op)
          stringizing the term taking in consideration operators declared in the engine.
(package private)  java.lang.String toStringAsArg(OperatorManager op, int prio, boolean x)
          stringize term as operator of priority prio.
(package private)  java.lang.String toStringAsArgX(OperatorManager op, int prio)
          stringize term t as arg X of operator op with priority prio.
(package private)  java.lang.String toStringAsArgY(OperatorManager op, int prio)
          stringize term as arg Y of operator op with priority prio.
 boolean unify(Term t, int m)
          tries to unify a term with the provided term argument.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

static final int NULL
See Also:
Constant Field Values

VAR

static final int VAR
See Also:
Constant Field Values

INT

static final int INT
See Also:
Constant Field Values

FLOAT

static final int FLOAT
See Also:
Constant Field Values

STRUCT

static final int STRUCT
See Also:
Constant Field Values

OBJECT

static final int OBJECT
See Also:
Constant Field Values

TRUE

public static final Struct TRUE

FALSE

public static final Struct FALSE

id

protected int id

value

private java.lang.Object value

longValue

private long longValue

doubleValue

private double doubleValue
Constructor Detail

Term

public Term(int v)
constructs an integer prolog term using an int.


Term

public Term(long v)
constructs an integer prolog term using a long.


Term

public Term(float v)
constructs a real prolog term using a float.


Term

public Term(double v)
constructs a real prolog term using a double.


Term

public Term(java.lang.Object t)
constructs a term incapsulating a java object.


Term

protected Term()
Method Detail

clone

public java.lang.Object clone()
cloning the term.


getInt

public int getInt()
gets term int value.


getLong

public long getLong()
gets term long value.


getFloat

public float getFloat()
gets term float value.


getDouble

public final double getDouble()
gets term double value.


getObject

public java.lang.Object getObject()
gets term object value


getTerm

public Term getTerm()
gets the actual term of the object.

if the Term is a bound variable, the method get the Term linked to the variable


getString

public java.lang.String getString(int index)
significant only for Struct derived class.


getObject

public java.lang.Object getObject(int index)
significant only for Struct derived class.


getTerm

public Term getTerm(int index)
significant only for Struct derived class.


getStruct

public Struct getStruct(int index)
significant only for Struct derived class.


getStruct

public Struct getStruct(java.lang.String name)
significant only for Struct derived class.


getName

public java.lang.String getName()
significant only for Var and Struct derived class.


getVar

public Term getVar(java.lang.String name)
significant only for Struct derived class.


toRawString

public java.lang.String toRawString()
significant only for Struct derived class; for real Term it's like toString


isConst

public boolean isConst()
is it a constant prolog term?


isNum

public boolean isNum()
is it a prolog numeric term?


isInt

public final boolean isInt()
is it a prolog integer term?


isStruct

public final boolean isStruct()
is it a struct


isFloat

public final boolean isFloat()
is it a prolog float term?


isObject

public final boolean isObject()
is it a prolog incapsulating a java object?


isVar

public final boolean isVar()
is it a prolog variable?


isCompound

public boolean isCompound()
is it a prolog compound term?


isAtom

public boolean isAtom()
is it a prolog (alphanumeric) atom?


isClause

public boolean isClause()
is it a prolog clause?


isList

public boolean isList()
is it a prolog list?


isEmptyList

public boolean isEmptyList()
is it a prolog empty list?


isTrue

public boolean isTrue()
is it a prolog true atom?


isFalse

public boolean isFalse()
is it a prolog false atom?


isAny

public boolean isAny()
is it a prolog any(_) variable?


isGround

public boolean isGround()
is it a ground term?


unify

public boolean unify(Term t,
                     int m)
tries to unify a term with the provided term argument.

Try the unification among the term and the term specified The unification is qualified with the integer passed as argument m in order to make reverisble unification using free(int), passing a code >= of m


match

public boolean match(Term t)
matching without unification; only true or false, without bindings.


renameVars

public int renameVars(int count)
renaming variables of the term starting from specified count.


renameVars

int renameVars(alice.util.LinkedList vars,
               int count)

free

public void free(int m)
significant for Var terms.


copy

public Term copy(alice.util.LinkedList vl)
gets a copy (with renamed variables) of the term.

the list argument passed contains the list of variables to be renamed (if empty list then no renaming)


isGT

public boolean isGT(Term t)
is term greater than term t?


isEQU

public boolean isEQU(Term t)
is term equal to term t?


parse

public static Term parse(java.lang.String st)
parse a Term from a string.

only default parser operator are recognized


parse

static Term parse(java.lang.String st,
                  OperatorManager op)
parse a Term from a string.

(operators currently defined by engine are recognized)


parseSentence

static Term parseSentence(java.lang.String st,
                          OperatorManager op)

getIterator

public static java.util.Iterator getIterator(java.lang.String text)
gets an iterator that provides a term stream from a source text.


toString

public java.lang.String toString()
stringizing the term without taking in consideration operators.


toString

public java.lang.String toString(OperatorManager op)
stringizing the term taking in consideration operators declared in the engine.


toStringAsArgX

java.lang.String toStringAsArgX(OperatorManager op,
                                int prio)
stringize term t as arg X of operator op with priority prio.


toStringAsArgY

java.lang.String toStringAsArgY(OperatorManager op,
                                int prio)
stringize term as arg Y of operator op with priority prio.


toStringAsArg

java.lang.String toStringAsArg(OperatorManager op,
                               int prio,
                               boolean x)
stringize term as operator of priority prio.

x true then X arg, if false then Y arg; actually for example +(a,*(b,c)) becomes 5+6*3

significant only for Struct Term