Class AbstractTerm

This class provides writing, reading, unification and copying of Prolog terms. The Java to Prolog API does provide specific data types for all Prolog terms. But the end-user has choices, he might have Prolog atomics unwrapped. Only compounds and variables need always be wrapped, since the API data type aggregates a skeleton and display.

The external API roots the terms either in the Java Object class or in the Term class. In both cases the hashCode(), equals() and toString() methods of the Java Object class can be used. The realization is such that that even for non-ground Prolog terms these methods correspond to the Prolog term_hash/2, ==/2 and write/1.

The method unifyTerm() attempts a unification. For performance reasons a failed unification might leave variable bindings. If the variable bindings need an undoing by the application program it is bested to use unification in combination with an empty interactor, see also the class Interpreter.

The method copyTerm() creates a copy of the given term. The method will create new com-pounds for those sub branches of the original term that either contain variables or that need to dereference variables or don't lead to atomics. The method variant copyTermWrapped() returns a wrapped result which preserves the call-site for atoms.

package jekpro.tools.term;

public abstract class AbstractTerm {
public static Object createTerm(Object m, Display d)
public static AbstractTerm createTermWrapped(Object m, Display d)
public static Object createMolec(Object m, Display d)
public static Object getSkel(Object t)
public static Display getDisplay(Object t);

public String toString();
public String toString(int flags);

public static Bind markBind(Interpreter inter);
 public static boolean unifyTerm(Interpreter inter,
Object fst, Object snd)
throws InterpreterException;
public static void releaseBind(Interpreter inter, Bind mark)
throws InterpreterException;

public static Object copyTerm(Interpreter inter, Object t);
public static AbstractTerm copyTermWrapped(Interpreter inter,
Object t);
public static Object copyMolec(Interpreter inter,
Object t);
}

Comments