alice.tuprolog
Class Var

java.lang.Object
  extended byalice.tuprolog.Term
      extended byalice.tuprolog.Var
All Implemented Interfaces:
java.io.Serializable

public class Var
extends Term

This class represents a variable term. Variables are identified by a name (which must starts with an upper case letter) or the anonymous ('_') name.

See Also:
Term, Serialized Form

Field Summary
 
Fields inherited from class alice.tuprolog.Term
FALSE, TRUE
 
Constructor Summary
Var()
          Creates an anonymous variable This is equivalent to build a variable with name _
Var(java.lang.String n)
          Creates a variable identified by a name.
 
Method Summary
 Term copy()
          Gets a copy of this variable
 java.lang.String getName()
          Gets the name of the variable
 Term getTerm()
          Gets the term which is referred by the variable.
 boolean isAnonymous()
          Tests if this variable is ANY
 boolean isAtom()
          is this term a prolog (alphanumeric) atom?
 boolean isAtomic()
          is this term a constant prolog term?
 boolean isBound()
          Tests if this variable is bound
 boolean isCompound()
          is this term a prolog compound term?
 boolean isEqual(Term t)
          Tests if this term is (logically) equal to another
 boolean isGreater(Term t)
          is term greater than term t?
 boolean isGround()
          is this term a ground term?
 boolean isList()
          is this term a prolog list?
 boolean isNull()
          is this term a null term?
 boolean isNumber()
          is this term a prolog numeric term?
 boolean isResolved()
          Tests if this variable is resolved
 boolean isStruct()
          is this term a struct
 boolean isVar()
          is this term a variable
 java.lang.String toString()
          Gets the string representation of this variable.
 java.lang.String toStringFlattened()
          Gets the string representation of this variable, providing the string representation of the linked term in the case of bound variable
 
Methods inherited from class alice.tuprolog.Term
equals, getIterator, getRenamedCopy, match, parse, parse, resolveVariables, unify
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Var

public Var(java.lang.String n)
    throws InvalidVarNameException
Creates a variable identified by a name. The name must starts with an upper case letter or the underscore. If an underscore is specified as a name, the variable is anonymous.

Parameters:
n - is the name
Throws:
InvalidVarNameException - if n is not a valid name

Var

public Var()
Creates an anonymous variable This is equivalent to build a variable with name _

Method Detail

getName

public java.lang.String getName()
Gets the name of the variable


getTerm

public Term getTerm()
Gets the term which is referred by the variable. For unbound variable it is the variable itself, while for bound variable it is the bound term.

Specified by:
getTerm in class Term

isNumber

public boolean isNumber()
is this term a prolog numeric term?

Specified by:
isNumber in class Term

isStruct

public boolean isStruct()
is this term a struct

Specified by:
isStruct in class Term

isVar

public boolean isVar()
is this term a variable

Specified by:
isVar in class Term

isNull

public boolean isNull()
Description copied from class: Term
is this term a null term?

Specified by:
isNull in class Term

isAtomic

public boolean isAtomic()
Description copied from class: Term
is this term a constant prolog term?

Specified by:
isAtomic in class Term

isCompound

public boolean isCompound()
Description copied from class: Term
is this term a prolog compound term?

Specified by:
isCompound in class Term

isAtom

public boolean isAtom()
Description copied from class: Term
is this term a prolog (alphanumeric) atom?

Specified by:
isAtom in class Term

isList

public boolean isList()
Description copied from class: Term
is this term a prolog list?

Specified by:
isList in class Term

isGround

public boolean isGround()
Description copied from class: Term
is this term a ground term?

Specified by:
isGround in class Term

isAnonymous

public boolean isAnonymous()
Tests if this variable is ANY


isBound

public boolean isBound()
Tests if this variable is bound


isResolved

public boolean isResolved()
Tests if this variable is resolved


copy

public Term copy()
Gets a copy of this variable

Specified by:
copy in class Term

isGreater

public boolean isGreater(Term t)
Description copied from class: Term
is term greater than term t?

Specified by:
isGreater in class Term

isEqual

public boolean isEqual(Term t)
Description copied from class: Term
Tests if this term is (logically) equal to another

Specified by:
isEqual in class Term

toString

public java.lang.String toString()
Gets the string representation of this variable. For bounded variables, the string is /.


toStringFlattened

public java.lang.String toStringFlattened()
Gets the string representation of this variable, providing the string representation of the linked term in the case of bound variable



DEIS, Universita' di Bologna, Sede di Cesena