se.sics.prologbeans
Class Term

java.lang.Object
  |
  +--se.sics.prologbeans.Term
Direct Known Subclasses:
PBAtomic, PBCompound

public abstract class Term
extends java.lang.Object

Term is the base for Java representations of Prolog terms.


Field Summary
protected  java.lang.String name
           
 
Method Summary
 double doubleValue()
          Returns the floating-point value of this term.
 float floatValue()
          Returns the floating-point value of this term.
 Term getArgument(int index)
          Returns the argument at the specified index.
 int getArity()
          Returns the number of arguments of this compound term or 0 if this term is not a compound term.
 java.lang.String getName()
          Returns the name of this constant or compound term.
 int intValue()
          Returns the integer value of this term.
 boolean isAtom()
          Returns true if this term is an atom and false otherwise.
 boolean isAtomic()
          Returns true if this term is a constant (e.g.
 boolean isCompound()
          Returns true if this term is a compund term and false otherwise.
 boolean isFloat()
          Returns true if this term is a floating-point number and false otherwise.
 boolean isInteger()
          Returns true if this term is an integer and false otherwise.
 boolean isList()
          Returns true if this term is a list and false otherwise.
 boolean isString()
          Returns true if this term is an instance of PBString (which can be used for fast string access) and false otherwise.
 boolean isVariable()
          Returns true if this term is a variable and false otherwise.
 long longValue()
          Returns the integer value of this term.
protected  java.lang.String stuffAtom(java.lang.String atom)
           
abstract  java.lang.String toString()
          Returns a string description of this term.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected final java.lang.String name
Method Detail

isAtom

public boolean isAtom()
Returns true if this term is an atom and false otherwise.

isInteger

public boolean isInteger()
Returns true if this term is an integer and false otherwise.

isFloat

public boolean isFloat()
Returns true if this term is a floating-point number and false otherwise.

isCompound

public boolean isCompound()
Returns true if this term is a compund term and false otherwise.

isList

public boolean isList()
Returns true if this term is a list and false otherwise.

isString

public boolean isString()
Returns true if this term is an instance of PBString (which can be used for fast string access) and false otherwise.

isAtomic

public boolean isAtomic()
Returns true if this term is a constant (e.g. integer, floating-point number, or atom) and false if this term is a compound term or variable.

isVariable

public boolean isVariable()
Returns true if this term is a variable and false otherwise.

getName

public java.lang.String getName()
Returns the name of this constant or compound term.

getArgument

public Term getArgument(int index)
Returns the argument at the specified index. Only compound terms have arguments. Note: the arguments are indexed from 1 to arity.
Parameters:
index - the (one based) index of the argument
Returns:
the argument as a Term
Throws:
java.lang.IllegalStateException - if this term is not compound

getArity

public int getArity()
Returns the number of arguments of this compound term or 0 if this term is not a compound term.

intValue

public int intValue()
Returns the integer value of this term.
Throws:
java.lang.IllegalStateException - if this term is not an integer

longValue

public long longValue()
Returns the integer value of this term.
Throws:
java.lang.IllegalStateException - if this term is not an integer

floatValue

public float floatValue()
Returns the floating-point value of this term.
Throws:
java.lang.IllegalStateException - if this term is not a number

doubleValue

public double doubleValue()
Returns the floating-point value of this term.
Throws:
java.lang.IllegalStateException - if this term is not a number

toString

public abstract java.lang.String toString()
Returns a string description of this term.
Overrides:
toString in class java.lang.Object

stuffAtom

protected java.lang.String stuffAtom(java.lang.String atom)