public abstract class PBTerm
extends java.lang.Object
PBTerm
is the Java representations
of Prolog terms.Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
name |
static PBTerm |
NIL
The
PBTerm NIL , with the
printname "[]", represents the empty list. |
Modifier and Type | Method and Description |
---|---|
java.math.BigInteger |
bigIntegerValue()
Returns the
BigInteger value of this
PBTerm . |
double |
floatValue()
Returns the floating-point value of this PBTerm.
|
PBTerm |
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
PBTerm is not a compound term. |
java.lang.String |
getName()
Returns the name of this constant or compound term.
|
java.lang.String |
getString()
If this
PBTerm is a proper list and all its
elements are small integers (less than 256), returns a
String with the list elements as the character
codes of the String . |
PBTerm |
head()
Returns the head of this
PBTerm if it is a
list cell, i.e. a compound term with the functor ./2. |
long |
intValue()
Returns the integer value of this
PBTerm . |
boolean |
isAtom()
|
boolean |
isAtomic()
|
boolean |
isBignum()
|
boolean |
isCompound()
|
boolean |
isEmptyList()
|
boolean |
isFloat()
|
boolean |
isInteger()
|
boolean |
isListCell()
Returns
true if this PBTerm is a
list cell, i.e. a compound term with the functor ./2, and
false otherwise. |
boolean |
isNumber()
|
boolean |
isProperList()
|
boolean |
isString()
Returns
true if this PBTerm is a
proper list and all of its elements are character codes or one character
atoms. |
boolean |
isVariable()
|
int |
length()
If this
PBTerm is a proper list, returns its
length. |
static PBTerm |
makeAtom(java.lang.String value)
Creates a new
PBTerm instance representing an
atom. |
static PBTerm |
makeTerm(java.math.BigInteger value)
Creates a new
PBTerm instance representing a
BigInteger value. |
static PBTerm |
makeTerm(double value)
Creates a new
PBTerm instance representing a
double value. |
static PBTerm |
makeTerm(float value)
Creates a new
PBTerm instance representing a
float value. |
static PBTerm |
makeTerm(int value)
Creates a new
PBTerm instance representing an
int value. |
static PBTerm |
makeTerm(long value)
Creates a new
PBTerm instance representing a
long value. |
static PBTerm |
makeTerm(PBTerm head,
PBTerm tail)
Creates a new
PBTerm instance representing a
list cell. |
static PBTerm |
makeTerm(java.lang.String value)
Creates a new
PBTerm instance representing a
list with the characters, as integer values, in the string argument as
its elements. |
static PBTerm |
makeTerm(java.lang.String name,
PBTerm[] arguments)
Creates a new
PBTerm instance representing a
compound term. |
protected java.lang.String |
stuffAtom(java.lang.String atom) |
PBTerm |
tail()
Returns the tail of this
PBTerm if it is a
list cell, i.e. a compound term with the functor ./2. |
abstract java.lang.String |
toString()
Returns a string description of this term.
|
public static final PBTerm NIL
PBTerm
NIL
, with the
printname "[]", represents the empty list.protected final java.lang.String name
public boolean isAtom()
public boolean isAtomic()
public boolean isNumber()
public boolean isInteger()
public boolean isBignum()
public boolean isFloat()
public boolean isCompound()
public boolean isListCell()
true
if this PBTerm
is a
list cell, i.e. a compound term with the functor ./2, and
false
otherwise.public boolean isProperList()
public boolean isEmptyList()
public boolean isString()
true
if this PBTerm
is a
proper list and all of its elements are character codes or one character
atoms. Returns false
otherwise.public PBTerm head()
PBTerm
if it is a
list cell, i.e. a compound term with the functor ./2.{@if.java
- java.lang. }IllegalStateException if this
PBTerm
is not a list cell.public PBTerm tail()
PBTerm
if it is a
list cell, i.e. a compound term with the functor ./2.{@if.java
- java.lang. }IllegalStateException if this
PBTerm
is not a list cell.public boolean isVariable()
public java.lang.String getName()
public PBTerm getArgument(int index)
index
- the (one based) index of the argumentPBTerm
{@if.java
- java.lang. }IllegalStateException if this term is not
compoundpublic int length()
PBTerm
is a proper list, returns its
length.{@if.java
- java.lang. }IllegalStateException if this
PBTerm
is not a proper list.public int getArity()
PBTerm
is not a compound term.public long intValue()
PBTerm
.{@if.java
- java.lang. }IllegalStateException if this
PBTerm
is not an integer.public java.math.BigInteger bigIntegerValue()
BigInteger
value of this
PBTerm
.{@if.java
- java.lang. }IllegalStateException if this
PBTerm
is not a bignum integer.BigInteger
public double floatValue()
{@if.java
- java.lang. }IllegalStateException if this
PBTerm
is not a number.public java.lang.String getString()
PBTerm
is a proper list and all its
elements are small integers (less than 256), returns a
String
with the list elements as the character
codes of the String
.{@if.java
- java.lang. }IllegalStateException if this
PBTerm
is not a proper list.public abstract java.lang.String toString()
toString
in class java.lang.Object
public static PBTerm makeTerm(float value)
PBTerm
instance representing a
float value.public static PBTerm makeTerm(double value)
PBTerm
instance representing a
double value.public static PBTerm makeTerm(int value)
PBTerm
instance representing an
int value.public static PBTerm makeTerm(long value)
PBTerm
instance representing a
long value.public static PBTerm makeTerm(java.math.BigInteger value)
PBTerm
instance representing a
BigInteger value.public static PBTerm makeTerm(java.lang.String value)
PBTerm
instance representing a
list with the characters, as integer values, in the string argument as
its elements.public static PBTerm makeTerm(java.lang.String name, PBTerm[] arguments)
PBTerm
instance representing a
compound term.public static PBTerm makeTerm(PBTerm head, PBTerm tail)
PBTerm
instance representing a
list cell.public static PBTerm makeAtom(java.lang.String value)
PBTerm
instance representing an
atom.protected java.lang.String stuffAtom(java.lang.String atom)