se.sics.prologbeans
Class PBTerm


PBTerm is the .NET representations of Prolog terms.


Field Summary
public static final PBTerm NIL
The PBTerm NIL, with the printname "[]", represents the empty list.

protected final string name

   
Method Summary
public bool isAtom()
Returns true if this PBTerm is an atom and false otherwise.
public bool isAtomic()
Returns true if this PBTerm is a constant (e.g. integer, floating-point number, or atom) and false if this PBTerm is a compound term or variable.
public bool isNumber()
Returns true if this PBTerm is a number and false otherwise.
public bool isInteger()
Returns true if this PBTerm is an integer and false otherwise.
public bool isBignum()
Returns true if this PBTerm is an bignum integer and false otherwise.
public bool isFloat()
Returns true if this PBTerm is a floating-point number and false otherwise.
public bool isCompound()
Returns true if this PBTerm is a compund term and false otherwise.
public bool isListCell()
Returns true if this PBTerm is a list cell, i.e. a compound term with the functor ./2, and false otherwise.
public bool isProperList()
Returns true if this PBTerm is a proper list and false otherwise.
public bool isEmptyList()
Returns true if this PBTerm is the empty list and false otherwise.
public bool isString()
Returns true if this PBTerm is a proper list and all of its elements are character codes or one character atoms.
public PBTerm head()
Returns the head of this PBTerm if it is a list cell, i.e.
public PBTerm tail()
Returns the tail of this PBTerm if it is a list cell, i.e.
public bool isVariable()
Returns true if this PBTerm is a variable and false otherwise.
public string getName()
Returns the name of this constant or compound term.
public PBTerm getArgument(int index)
Returns the argument at the specified index.
public int length()
If this PBTerm is a proper list, returns its length.
public int getArity()
Returns the number of arguments of this compound term or 0 if this PBTerm is not a compound term.
public long intValue()
Returns the integer value of this PBTerm.
public BigInteger bigIntegerValue()
Returns the BigInteger value of this PBTerm.
public double floatValue()
Returns the floating-point value of this PBTerm.
public 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.
public abstract string toString()
Returns a string description of this term.
public static PBTerm makeTerm(float value)
Creates a new PBTerm instance representing a float value.
public static PBTerm makeTerm(double value)
Creates a new PBTerm instance representing a double value.
public static PBTerm makeTerm(int value)
Creates a new PBTerm instance representing an int value.
public static PBTerm makeTerm(long value)
Creates a new PBTerm instance representing a long value.
public static PBTerm makeTerm(BigInteger value)
Creates a new PBTerm instance representing a BigInteger value.
public static PBTerm makeTerm(string value)
Creates a new PBTerm instance representing a list with the characters, as integer values, in the string argument as its elements.
public static PBTerm makeTerm(string name, PBTerm[] arguments)
Creates a new PBTerm instance representing a compound term.
public static PBTerm makeTerm(PBTerm head, PBTerm tail)
Creates a new PBTerm instance representing a list cell.
public static PBTerm makeAtom(string value)
Creates a new PBTerm instance representing an atom.
protected string stuffAtom(string atom)
 
Field Detail

NIL

public static final PBTerm NIL
The PBTerm NIL, with the printname "[]", represents the empty list.


name

protected final string name


   
Method Detail

isAtom

public bool isAtom()
Returns true if this PBTerm is an atom and false otherwise.


isAtomic

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


isNumber

public bool isNumber()
Returns true if this PBTerm is a number and false otherwise.


isInteger

public bool isInteger()
Returns true if this PBTerm is an integer and false otherwise.


isBignum

public bool isBignum()
Returns true if this PBTerm is an bignum integer and false otherwise.


isFloat

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


isCompound

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


isListCell

public bool isListCell()
Returns true if this PBTerm is a list cell, i.e. a compound term with the functor ./2, and false otherwise.


isProperList

public bool isProperList()
Returns true if this PBTerm is a proper list and false otherwise.


isEmptyList

public bool isEmptyList()
Returns true if this PBTerm is the empty list and false otherwise.


isString

public bool isString()
Returns true if this PBTerm is a proper list and all of its elements are character codes or one character atoms. Returns false otherwise.


head

public PBTerm head()
Returns the head of this PBTerm if it is a list cell, i.e. a compound term with the functor ./2.

Throws:
{@if.java - java.lang.}IllegalStateException if this PBTerm is not a list cell.

tail

public PBTerm tail()
Returns the tail of this PBTerm if it is a list cell, i.e. a compound term with the functor ./2.

Throws:
{@if.java - java.lang.}IllegalStateException if this PBTerm is not a list cell.

isVariable

public bool isVariable()
Returns true if this PBTerm is a variable and false otherwise.


getName

public string getName()
Returns the name of this constant or compound term.


getArgument

public PBTerm 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 PBTerm
Throws:
{@if.java - java.lang.}IllegalStateException if this term is not compound

length

public int length()
If this PBTerm is a proper list, returns its length.

Throws:
{@if.java - java.lang.}IllegalStateException if this PBTerm is not a proper list.

getArity

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


intValue

public long intValue()
Returns the integer value of this PBTerm.

Throws:
{@if.java - java.lang.}IllegalStateException if this PBTerm is not an integer.

bigIntegerValue

public BigInteger bigIntegerValue()
Returns the BigInteger value of this PBTerm.

Throws:
{@if.java - java.lang.}IllegalStateException if this PBTerm is not a bignum integer.

floatValue

public double floatValue()
Returns the floating-point value of this PBTerm.

Throws:
{@if.java - java.lang.}IllegalStateException if this PBTerm is not a number.

getString

public 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.

Throws:
{@if.java - java.lang.}IllegalStateException if this PBTerm is not a proper list.

toString

public abstract string toString()
Returns a string description of this term.


makeTerm

public static PBTerm makeTerm(float value)
Creates a new PBTerm instance representing a float value.


makeTerm

public static PBTerm makeTerm(double value)
Creates a new PBTerm instance representing a double value.


makeTerm

public static PBTerm makeTerm(int value)
Creates a new PBTerm instance representing an int value.


makeTerm

public static PBTerm makeTerm(long value)
Creates a new PBTerm instance representing a long value.


makeTerm

public static PBTerm makeTerm(BigInteger value)
Creates a new PBTerm instance representing a BigInteger value.


makeTerm

public static PBTerm makeTerm(string value)
Creates a new PBTerm instance representing a list with the characters, as integer values, in the string argument as its elements.


makeTerm

public static PBTerm makeTerm(string name, PBTerm[] arguments)
Creates a new PBTerm instance representing a compound term.


makeTerm

public static PBTerm makeTerm(PBTerm head, PBTerm tail)
Creates a new PBTerm instance representing a list cell.


makeAtom

public static PBTerm makeAtom(string value)
Creates a new PBTerm instance representing an atom.


stuffAtom

protected string stuffAtom(string atom)