Prolog Cafe v1.2

jp.ac.kobe_u.cs.prolog.lang
Class StructureTerm

java.lang.Object
  extended by jp.ac.kobe_u.cs.prolog.lang.Term
      extended by jp.ac.kobe_u.cs.prolog.lang.StructureTerm
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Term>

public class StructureTerm
extends Term

Compound term.
The StructureTerm class represents a compound term but list.

  % father(abraham, X)
  Term a1 = SymbolTerm.makeSymbol("abraham");
  Term a2 = new VariableTerm();
  Term[] a3 = {a1, a2};
  Term a4 = SymbolTerm.makeSymbol("father", 2);
  Term  t = new StructureTerm(a4, a3);
  
  Term functor = ((StructureTerm)t).functor();
  Term[]  args = ((StructureTerm)t).args();
  int    arity = ((StructureTerm)t).arity();
 

See Also:
Serialized Form

Field Summary
protected  Term[] args
          Holds the argument terms of this StructureTerm.
protected  int arity
          Holds the arity of this StructureTerm.
protected  SymbolTerm functor
          Holds the functor symbol of this StructureTerm.
 
Fields inherited from class jp.ac.kobe_u.cs.prolog.lang.Term
AFTER, BEFORE, EQUAL
 
Constructor Summary
StructureTerm(SymbolTerm _functor, Term[] _args)
          Constructs a new Prolog compound term such that _functor is the functor symbol, and _args is the argument terms respectively.
 
Method Summary
 Term[] args()
          Returns the argument terms of this StructureTerm.
 int arity()
          Returns the arity of this StructureTerm.
 int compareTo(Term anotherTerm)
          Compares two terms in Prolog standard order of terms.
protected  Term copy(Prolog engine)
          Returns a copy of this object.
 boolean equals(java.lang.Object obj)
          Checks term equality of two terms.
 SymbolTerm functor()
          Returns the functor symbol of this StructureTerm.
 int hashCode()
           
 boolean isGround()
          Check whether this term is a ground term.
 java.lang.String name()
          Returns the string representation of functor symbol of this StructureTerm.
 java.lang.String toQuotedString()
          Returns a quoted string representation of this term.
 java.lang.String toString()
          Returns a string representation of this StructureTerm.
 boolean unify(Term t, Trail trail)
          Checks whether the argument term is unified with this one.
 
Methods inherited from class jp.ac.kobe_u.cs.prolog.lang.Term
convertible, convertible, dereference, instanceOfTerm, isClosure, isDouble, isInteger, isJavaObject, isList, isNil, isNumber, isStructure, isSymbol, isVariable, toJava
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

functor

protected SymbolTerm functor
Holds the functor symbol of this StructureTerm.


args

protected Term[] args
Holds the argument terms of this StructureTerm.


arity

protected int arity
Holds the arity of this StructureTerm.

Constructor Detail

StructureTerm

public StructureTerm(SymbolTerm _functor,
                     Term[] _args)
Constructs a new Prolog compound term such that _functor is the functor symbol, and _args is the argument terms respectively.

Method Detail

functor

public SymbolTerm functor()
Returns the functor symbol of this StructureTerm.

Returns:
the value of functor.
See Also:
functor

arity

public int arity()
Returns the arity of this StructureTerm.

Returns:
the value of arity.
See Also:
arity

args

public Term[] args()
Returns the argument terms of this StructureTerm.

Returns:
the value of args.
See Also:
args

name

public java.lang.String name()
Returns the string representation of functor symbol of this StructureTerm.

Returns:
a String whose value is functor.name().
See Also:
functor, SymbolTerm.name

unify

public boolean unify(Term t,
                     Trail trail)
Description copied from class: Term
Checks whether the argument term is unified with this one.

Specified by:
unify in class Term
Parameters:
t - the term to be unified with.
trail - Trail Stack.
Returns:
true if succeeds, otherwise false.

copy

protected Term copy(Prolog engine)
Description copied from class: Term
Returns a copy of this object.

Overrides:
copy in class Term

isGround

public boolean isGround()
Description copied from class: Term
Check whether this term is a ground term.

Overrides:
isGround in class Term
Returns:
true if ground, otherwise false.

toQuotedString

public java.lang.String toQuotedString()
Description copied from class: Term
Returns a quoted string representation of this term.

Overrides:
toQuotedString in class Term

equals

public boolean equals(java.lang.Object obj)
Checks term equality of two terms. The result is true if and only if the argument is an instance of StructureTerm, has the same functor symbol and arity, and all corresponding pairs of arguments in the two compound terms are term-equal.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with. This must be dereferenced.
Returns:
true if the given object represents a Prolog compound term equivalent to this StructureTerm, false otherwise.
See Also:
compareTo(jp.ac.kobe_u.cs.prolog.lang.Term)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of this StructureTerm.

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(Term anotherTerm)
Compares two terms in Prolog standard order of terms.
It is noted that t1.compareTo(t2) == 0 has the same boolean value as t1.equals(t2).

Parameters:
anotherTerm - the term to compared with. It must be dereferenced.
Returns:
the value 0 if two terms are identical; a value less than 0 if this term is before the anotherTerm; and a value greater than 0 if this term is after the anotherTerm.

Prolog Cafe v1.2

Copyright (C) 1997-2008 M.BANBARA and N.TAMURA