jpl

Class Term

public abstract class Term extends Object

Term is the abstract base class for Compound, Atom, Variable, Integer and Float, which comprise a Java-oriented concrete syntax for Prolog. You cannot create instances of Term directly; rather, you should create instances of Term's concrete subclasses. Alternatively, use textToTerm() to construct a Term from its conventional Prolog source text representation.
Copyright (C) 2004 Paul Singleton

Copyright (C) 1998 Fred Dushin

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library Public License for more details.


Method Summary
Termarg(int ano)
returns the ano-th (1+) argument of a (Compound) Term throws a JPLException for any other subclass
abstract Term[]args()
returns, as a Term[], the arguments of a Compound returns an empty Term[] from an Atom, Integer or Float throws a JPLException from a Variable
intarity()
returns, as an int, the arity of a Compound, Atom, Integer or Float throws a JPLException from a Variable
abstract StringdebugString()
Returns a debug-friendly representation of a Term
static StringdebugString(Term[] arg)
Returns a debug-friendly representation of a list of Terms
doubledoubleValue()
returns the value (as a double) of an Integer or Float throws a JPLException from any other subclass
floatfloatValue()
returns the value (as a float) of an Integer or Float throws a JPLException from a Compound, Atom or Variable
booleanhasFunctor(String name, int arity)
Tests whether this Term's functor has (String) 'name' and 'arity' Returns false if called inappropriately
booleanhasFunctor(int value, int arity)
Tests whether this Term's functor has (int) 'name' and 'arity' Returns false if called inappropriately
booleanhasFunctor(double value, int arity)
Tests whether this Term's functor has (double) 'name' and 'arity' Returns false if called inappropriately
intintValue()
returns the value (as an int) of an Integer or Float throws a JPLException from a Compound, Atom or Variable
booleanisAtom()
whether this Term represents an atom
booleanisCompound()
whether this Term represents a compound term
booleanisFloat()
whether this Term represents an atom
booleanisInteger()
whether this Term represents an atom
booleanisJFalse()
whether this Term is a 'jfalse' structure, i.e.
booleanisJNull()
whether this Term is a 'jnull' structure, i.e.
booleanisJObject()
whether this Term is a 'jobject' structure, i.e.
booleanisJRef()
whether this Term is a 'jref' structure, i.e.
booleanisJTrue()
whether this Term is a 'jtrue' structure, i.e.
booleanisJVoid()
whether this Term is a 'jvoid' structure, i.e.
booleanisVariable()
whether this Term is a variable
intlistLength()
the length of this list, iff it is one, else an exception is thrown
longlongValue()
returns the value (as a long) of an Integer or Float throws a JPLException from a Compound, Atom or Variable
Stringname()
returns, as a String, the name of a Compound, Atom or Variable throws a JPLException from an Integer or Float
voidput(term_t term)
TermputParams(Term[] ps)
TermputParams(Term plist)
static voidputTerm(Object obj, term_t termref)
static StringtoString(Term[] args)
Converts a list of Terms to a String.
Term[]toTermArray()
returns an array of terms which are the successive members of this list, if it is a list, else throws an exception
abstract inttype()
returns the type of this term, as one of jpl.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etc
abstract StringtypeName()
returns the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" etc

Method Detail

arg

public Term arg(int ano)
returns the ano-th (1+) argument of a (Compound) Term throws a JPLException for any other subclass

Returns: the ano-th argument of a (Compound) Term

args

public abstract Term[] args()
returns, as a Term[], the arguments of a Compound returns an empty Term[] from an Atom, Integer or Float throws a JPLException from a Variable

Returns: the arguments of a Compound as a Term[

arity

public int arity()
returns, as an int, the arity of a Compound, Atom, Integer or Float throws a JPLException from a Variable

Returns: the arity of a Compound, Atom, Integer or Float

debugString

public abstract String debugString()

Deprecated:

Returns a debug-friendly representation of a Term

Returns: a debug-friendly representation of a Term

debugString

public static String debugString(Term[] arg)

Deprecated:

Returns a debug-friendly representation of a list of Terms

Returns: a debug-friendly representation of a list of Terms

doubleValue

public double doubleValue()
returns the value (as a double) of an Integer or Float throws a JPLException from any other subclass

Returns: the value (as an double) of an Integer or Float

floatValue

public float floatValue()
returns the value (as a float) of an Integer or Float throws a JPLException from a Compound, Atom or Variable

Returns: the value (as a float) of an Integer or Float

hasFunctor

public boolean hasFunctor(String name, int arity)
Tests whether this Term's functor has (String) 'name' and 'arity' Returns false if called inappropriately

Returns: whether this Term's functor has (String) 'name' and 'arity'

hasFunctor

public boolean hasFunctor(int value, int arity)
Tests whether this Term's functor has (int) 'name' and 'arity' Returns false if called inappropriately

Returns: whether this Term's functor has (int) 'name' and 'arity'

hasFunctor

public boolean hasFunctor(double value, int arity)
Tests whether this Term's functor has (double) 'name' and 'arity' Returns false if called inappropriately

Returns: whether this Term's functor has (double) 'name' and 'arity'

intValue

public int intValue()
returns the value (as an int) of an Integer or Float throws a JPLException from a Compound, Atom or Variable

Returns: the value (as an int) of an Integer or Float

isAtom

public boolean isAtom()
whether this Term represents an atom

Returns: whether this Term represents an atom

isCompound

public boolean isCompound()
whether this Term represents a compound term

Returns: whether this Term represents a compound atom

isFloat

public boolean isFloat()
whether this Term represents an atom

Returns: whether this Term represents an atom

isInteger

public boolean isInteger()
whether this Term represents an atom

Returns: whether this Term represents an atom

isJFalse

public boolean isJFalse()
whether this Term is a 'jfalse' structure, i.e. @(false)

Returns: whether this Term is a 'jfalse' structure, i.e. @(false)

isJNull

public boolean isJNull()
whether this Term is a 'jnull' structure, i.e. @(null)

Returns: whether this Term is a 'jnull' structure, i.e. @(null)

isJObject

public boolean isJObject()
whether this Term is a 'jobject' structure, i.e. @(Tag)

Returns: whether this Term is a 'jobject' structure, i.e. @(Tag)

isJRef

public boolean isJRef()
whether this Term is a 'jref' structure, i.e. @(Tag) or @(null)

Returns: whether this Term is a 'jref' structure, i.e. @(Tag) or @(null)

isJTrue

public boolean isJTrue()
whether this Term is a 'jtrue' structure, i.e. @(true)

Returns: whether this Term is a 'jtrue' structure, i.e. @(true)

isJVoid

public boolean isJVoid()
whether this Term is a 'jvoid' structure, i.e. @(void)

Returns: whether this Term is a 'jvoid' structure, i.e. @(void)

isVariable

public boolean isVariable()
whether this Term is a variable

Returns: whether this Term is a variable

listLength

public int listLength()
the length of this list, iff it is one, else an exception is thrown

Returns: the length (as an int) of this list, iff it is one

Throws: JPLException

longValue

public long longValue()
returns the value (as a long) of an Integer or Float throws a JPLException from a Compound, Atom or Variable

Returns: the value (as a long) of an Integer or Float

name

public String name()
returns, as a String, the name of a Compound, Atom or Variable throws a JPLException from an Integer or Float

Returns: the name of a Compound, Atom or Variable

put

public void put(term_t term)

putParams

public Term putParams(Term[] ps)

putParams

public Term putParams(Term plist)

putTerm

public static void putTerm(Object obj, term_t termref)

toString

public static String toString(Term[] args)
Converts a list of Terms to a String.

Parameters: args An array of Terms to convert

Returns: String representation of a list of Terms

toTermArray

public Term[] toTermArray()
returns an array of terms which are the successive members of this list, if it is a list, else throws an exception

Returns: an array of terms which are the successive members of this list, if it is a list

Throws: JPLException

type

public abstract int type()
returns the type of this term, as one of jpl.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etc

Returns: the type of this term, as one of jpl.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etc

typeName

public abstract String typeName()
returns the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" etc

Returns: the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" etc