public abstract class Term
extends java.lang.Object
Copyright (C) 1998 Fred Dushin
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Modifier and Type | Method and Description |
---|---|
Term |
arg(int i)
returns the i-th (1+) argument of a Term;
defined only for Compound
|
Term[] |
args()
The arguments of this Term.
|
int |
arity()
the arity of a Compound, Atom, Integer or Float
|
java.lang.String |
atomType() |
java.math.BigInteger |
bigValue()
the value (as a java.math.BigInteger) of an Integer, whether or not it is big
|
double |
doubleValue()
the value (as a double) of an Integer or Float
|
float |
floatValue()
the value (as a float) of an Integer or Float
|
boolean |
hasFunctor(java.math.BigInteger name,
int arity)
Tests whether this Term's functor has 'name' and 'arity'
|
boolean |
hasFunctor(double name,
int arity)
Tests whether this Term's functor has 'name' and 'arity'
|
boolean |
hasFunctor(long name,
int arity)
Tests whether this Term's functor has 'name' and 'arity'
|
boolean |
hasFunctor(java.lang.String name,
int arity)
Whether this Term's functor has 'name' and 'arity' (c.f.
|
int |
intValue()
returns the value (as an int) of an Integer or Float
|
boolean |
isAtom()
whether this Term is an Atom (of any type)
|
boolean |
isBig()
Tests whether this Integer's value is too big to represent as a long.
|
boolean |
isBigInteger()
Tests whether this Term is an Integer whose value is too big to represent as a long
|
boolean |
isCompound()
Tests whether this Term is a Compound.
|
boolean |
isFloat()
Tests whether this Term is an org.jpl7.Float.
|
boolean |
isInteger()
Tests whether this Term is an org.jpl7.Integer.
|
boolean |
isJFalse()
Tests whether this Term is a 'jfalse' structure, i.e.
|
boolean |
isJNull()
Tests whether this Term is a 'jnull' structure, i.e.
|
boolean |
isJRef()
Tests whether this Term is a (non-null, non-String) JPL reference to a Java object, e.g.
|
boolean |
isJTrue()
Tests whether this Term is a 'jtrue' structure, i.e.
|
boolean |
isJVoid()
Tests whether this Term is a 'jvoid' structure, i.e.
|
boolean |
isListNil()
Tests whether this Term denotes an empty list within the current syntax ("traditional" or "modern").
|
boolean |
isListPair()
Tests whether this Term is a list pair within the current syntax ("traditional" or "modern").
|
boolean |
isVariable()
Tests whether this Term is a Variable.
|
java.lang.Object |
jrefToObject()
Deprecated.
Use
JRef.object() |
int |
listLength()
Deprecated.
|
long |
longValue()
The (long) value of a Float or Integer.
|
java.lang.String |
name()
The name of an Atom, Compound or Variable.
|
java.lang.Object |
object()
The (non-null, non-String) Object which this org.jpl7.JRef refers to, iff this Term is a JRef.
|
static Term |
objectToJRef(java.lang.Object object)
Deprecated.
|
Term |
putParams(Term[] ps)
This internal method is public because it needs to be callable via JNI, but it is not part of JPL's public API
and should not be used by applications.
|
static void |
putTerm(java.lang.Object obj,
term_t termref) |
java.lang.Object |
ref()
Deprecated.
Use
JRef.object() |
static java.lang.String |
toString(Term[] args)
Converts a list of Terms to a String.
|
Term[] |
toTermArray()
returns an array of Terms whose elements are the respective members of this list, iff it is a list.
|
abstract int |
type()
returns the type of this term, as one of org.jpl7.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etc
|
abstract java.lang.String |
typeName()
returns the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" or "JRef"
|
public Term arg(int i)
JPLException
- if Term is not a Compoundpublic Term[] args()
Note that a SWI Prolog 7.x compound term can have zero arguments.
This method returns an empty Term[] from an Atom, Float, Integer or JRef, approximating the behaviour of SWI Prolog's =../2
JPLException
- if the Term is a Variablepublic int arity()
JPLException
- if the Term is a Variablepublic java.lang.String atomType()
JPLException
- if the Term is not an Atompublic java.math.BigInteger bigValue()
JPLException
- if the Term is not an Integerpublic double doubleValue()
JPLException
- if the Term is neither an Integer nor a Floatpublic float floatValue()
JPLException
- if the Term is neither an Integer nor a Floatpublic boolean hasFunctor(java.lang.String name, int arity)
name
- a possible name for the functor of a termarity
- an arity 0+JPLException
- if this Term is a Variablepublic boolean hasFunctor(long name, int arity)
For Float and Integer, mimics behaviour of SWI Prolog's functor/3
name
- a possible name for the functor of a termarity
- an arity 0+JPLException
- if this Term is a Variablepublic boolean hasFunctor(java.math.BigInteger name, int arity)
For Float and Integer, mimics behaviour of SWI Prolog's functor/3
name
- a possible name for the functor of a termarity
- an arity 0+JPLException
- if this Term is a Variablepublic boolean hasFunctor(double name, int arity)
For Float and Integer, mimics behaviour of SWI Prolog's functor/3
name
- a possible name for the functor of a termarity
- an arity 0+JPLException
- if this Term is a Variablepublic int intValue()
JPLException
- if this Term is a Compound, Atom or Variablepublic final boolean isAtom()
public boolean isBig()
Use this in contexts where the Term is known to be an Integer.
JPLException
- if Term is not an org.jpl7.IntegerisBigInteger()
public boolean isBigInteger()
isBig()
public final boolean isCompound()
public final boolean isFloat()
public final boolean isInteger()
public boolean isJFalse()
public boolean isJNull()
public final boolean isJRef()
JRef.object()
public boolean isJTrue()
public boolean isJVoid()
public boolean isListNil()
JPL.getSyntax()
public boolean isListPair()
public final boolean isVariable()
public java.lang.Object jrefToObject()
JRef.object()
public final int listLength()
Util.listToLength(Term)
JPLException
public long longValue()
JPLException
- if this Term is not a Float or Integer.public java.lang.String name()
JPLException
- if this Term is not an Atom, Compound or Variable.public java.lang.Object object()
JPLException
- if this Term is not a JRef.public static final Term objectToJRef(java.lang.Object object)
JPL.newJRef(java.lang.Object)
JPLException
- if object is a String.public Term putParams(Term[] ps)
ps
- JPLException
- if there are more actual than formal parameters.public static void putTerm(java.lang.Object obj, term_t termref)
public java.lang.Object ref()
JRef.object()
JPLException
- if this Term is not a JRefpublic final Term[] toTermArray()
JPLException
- if this Term is not a proper list.public static java.lang.String toString(Term[] args)
args
- An array of Terms to convertpublic abstract int type()
public abstract java.lang.String typeName()