|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjpl.Term
jpl.Compound
public class Compound
A Compound represents a structured term, comprising a functor and arguments (Terms). Atom is a subclass of Compound, whose instances have zero arguments. Direct instances of Compound must have one or more arguments (it is an error to attempt to construct a Compound with zero args; a JPLException will be thrown). For example, this Java expression yields a representation of the term f(a):
new Compound( "f", new Term[] { new Atom("a") } )
Note the use of the "anonymous array" notation to denote the arguments
(an anonymous array of Term).
Util.textToTerm("f(a)")
The arity of a Compound is the quantity of its arguments.
Once constructed, neither the name nor the arity of a Compound can be altered.
An argument of a Compound can be replaced with the setArg() method.
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.
Term,
Atom| Constructor Summary | |
|---|---|
Compound(java.lang.String name,
int arity)
Creates a Compound with name and arity. |
|
Compound(java.lang.String name,
Term[] args)
Creates a Compound with name and args. |
|
| Method Summary | |
|---|---|
Term |
arg(int i)
Returns the ith argument (counting from 1) of this Compound; throws an ArrayIndexOutOfBoundsException if i is inappropriate. |
Term |
arg0(int i)
Deprecated. |
Term[] |
args()
Deprecated. |
int |
arity()
Returns the arity (1+) of this Compound. |
java.lang.String |
debugString()
Deprecated. |
boolean |
equals(java.lang.Object obj)
Two Compounds are equal if they are identical (same object) or their names and arities are equal and their respective arguments are equal. |
boolean |
hasFunctor(double value,
int arity)
Tests whether this Term's functor has (double) 'name' and 'arity' Returns false if called inappropriately |
boolean |
hasFunctor(int value,
int arity)
Tests whether this Term's functor has (int) 'name' and 'arity' Returns false if called inappropriately |
boolean |
hasFunctor(java.lang.String name,
int arity)
Tests whether this Compound's functor has (String) 'name' and 'arity'. |
boolean |
isJFalse()
whether this Term is a 'jboolean' structure denoting Java's false, i.e. |
boolean |
isJNull()
whether this Term is a 'jnull' structure, i.e. |
boolean |
isJObject()
whether this Term is a 'jobject' structure, i.e. |
boolean |
isJRef()
whether this Term is a 'jref' structure, i.e. |
boolean |
isJTrue()
whether this Term is a 'jboolean' structure denoting Java's true, i.e. |
boolean |
isJVoid()
whether this Term is a 'jvoid' structure, i.e. |
java.lang.Object |
jrefToObject()
|
java.lang.String |
name()
Returns the name (unquoted) of this Compound. |
void |
setArg(int i,
Term arg)
Sets the i-th (from 1) arg of this Compound to the given Term instance. |
java.lang.String |
toString()
Returns a prefix functional representation of a Compound of the form name(arg1,...), where 'name' is quoted iff necessary (to be valid Prolog soutce text) and each argument is represented according to its toString() method. |
int |
type()
returns the type of this term, as jpl.fli.Prolog.COMPOUND |
java.lang.String |
typeName()
returns the name of the type of this term, as "Compound" |
| Methods inherited from class jpl.Term |
|---|
debugString, doubleValue, floatValue, intValue, isAtom, isCompound, isFloat, isInteger, isVariable, listLength, longValue, objectToJRef, put, putParams, putParams, putTerm, toString, toTermArray |
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Compound(java.lang.String name,
Term[] args)
name - the name of this Compoundargs - the (one or more) arguments of this Compound
public Compound(java.lang.String name,
int arity)
name - the name of this Compoundarity - the arity of this Compound| Method Detail |
|---|
public final Term arg(int i)
arg in class Term
public final boolean hasFunctor(java.lang.String name,
int arity)
hasFunctor in class Termpublic boolean isJFalse()
isJFalse in class Termpublic boolean isJTrue()
isJTrue in class Termpublic boolean isJNull()
isJNull in class Termpublic boolean isJVoid()
isJVoid in class Termpublic boolean isJObject()
isJObject in class Termpublic boolean isJRef()
isJRef in class Termpublic java.lang.Object jrefToObject()
jrefToObject in class Termpublic final java.lang.String name()
name in class Termpublic final int arity()
arity in class Termpublic java.lang.String toString()
toString in class java.lang.Objectpublic final boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the Object to compare (not necessarily another Compound)
public int type()
type in class Termpublic java.lang.String typeName()
typeName in class Term
public void setArg(int i,
Term arg)
i - the index (1+) of the arg to be setarg - the Term which is to become the i-th (from 1) arg of this Compoundpublic final Term[] args()
args in class Termpublic final Term arg0(int i)
public java.lang.String debugString()
debugString in class Term
public boolean hasFunctor(int value,
int arity)
Term
hasFunctor in class Term
public boolean hasFunctor(double value,
int arity)
Term
hasFunctor in class Term
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||