Prolog Cafe v1.2

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

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

public class JavaObjectTerm
extends Term

Java-term.
The JavaObjectTerm class wraps a java object.

  import java.util.Hashtable;
  Term t = new JavaObjectTerm(new Hashtable());
  Hashtable hash = (Hashtable)(((JavaObjectTerm)t).object());
 

See Also:
Serialized Form

Field Summary
protected  java.lang.Class clazz
          Holds a java.lang.Class of object wrapped by this JavaObjectTerm.
protected  java.lang.Object obj
          Holds a java object that this JavaObjectTerm wraps.
 
Fields inherited from class jp.ac.kobe_u.cs.prolog.lang.Term
AFTER, BEFORE, EQUAL
 
Constructor Summary
JavaObjectTerm(java.lang.Object _obj)
          Constructs a new Prolog java-term that wraps the argument object.
 
Method Summary
 int compareTo(Term anotherTerm)
          Compares two terms in Prolog standard order of terms.
 boolean convertible(java.lang.Class type)
          Check whether the wrapped object is convertible with the given Java class type.
 boolean equals(java.lang.Object o)
          Checks term equality of two terms.
 java.lang.Class getClazz()
          Returns a java.lang.Class of object wrapped by this JavaObjectTerm.
 int hashCode()
           
 java.lang.Object object()
          Returns the object wrapped by this JavaObjectTerm.
 void setObject(java.lang.Object _obj)
          Sets the argument object to this JavaObjectTerm.
 java.lang.Object toJava()
          Returns the object wrapped by this JavaObjectTerm.
 java.lang.String toQuotedString()
          Returns a quoted string representation of this term.
 java.lang.String toString()
          Returns a string representation of this JavaObjectTerm.
 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, copy, dereference, instanceOfTerm, isClosure, isDouble, isGround, isInteger, isJavaObject, isList, isNil, isNumber, isStructure, isSymbol, isVariable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

obj

protected java.lang.Object obj
Holds a java object that this JavaObjectTerm wraps.


clazz

protected java.lang.Class clazz
Holds a java.lang.Class of object wrapped by this JavaObjectTerm.

Constructor Detail

JavaObjectTerm

public JavaObjectTerm(java.lang.Object _obj)
Constructs a new Prolog java-term that wraps the argument object.

Method Detail

setObject

public void setObject(java.lang.Object _obj)
Sets the argument object to this JavaObjectTerm.


object

public java.lang.Object object()
Returns the object wrapped by this JavaObjectTerm.


getClazz

public java.lang.Class getClazz()
Returns a java.lang.Class of object wrapped by this JavaObjectTerm.


toQuotedString

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

Overrides:
toQuotedString in class Term

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.

convertible

public boolean convertible(java.lang.Class type)
Check whether the wrapped object is convertible with the given Java class type.

Overrides:
convertible in class Term
Parameters:
type - the Java class type to compare with.
Returns:
the boolean whose value is convertible(clazz, type).
See Also:
clazz, Term.convertible(Class, Class)

toJava

public java.lang.Object toJava()
Returns the object wrapped by this JavaObjectTerm.

Overrides:
toJava in class Term
Returns:
the value of obj.
See Also:
obj

equals

public boolean equals(java.lang.Object o)
Checks term equality of two terms. The result is true if and only if the argument is an instance of JavaObjectTerm, and the pairs of wrapped objects in the two java-term are equal by obj.equals(((JavaObjectTerm)o).obj).

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare with. This must be dereferenced.
Returns:
true if the given object represents a java-term equivalent to this JavaObjectTerm, 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 JavaObjectTerm.

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