jpl
Class Util

java.lang.Object
  extended byjpl.Util

public final class Util
extends java.lang.Object

This class provides a bunch of static utility methods for the JPL High-Level Interface.


Copyright (C) 2004 Paul Singleton

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.


Version:
$Revision: 1.2 $

Constructor Summary
Util()
           
 
Method Summary
static Term[] bindingsToTermArray(java.util.Map varnames_to_Terms)
          Converts a solution hashtable to an array of Terms.
static java.util.Map namevarsToMap(Term nvs)
          Converts a (JPL) list of Name=Var pairs (as yielded by atom_to_term/3) to a Map from Prolog variables (necessarily in term_t holders) to named JPL Variables
static Term termArrayToList(Term[] terms)
          Converts an array of Terms to a JPL representation of a Prolog list of terms whose members correspond to the respective array elements.
static Term textToTerm(java.lang.String text)
          Converts a Prolog source text to a corresponding JPL Term (in which each Variable has the appropriate name from the source text).
static java.lang.String toString(java.util.Map varnames_to_Terms)
          Converts a substitution, in the form of a Map from variable names to Terms, to a String.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

termArrayToList

public static Term termArrayToList(Term[] terms)
Converts an array of Terms to a JPL representation of a Prolog list of terms whose members correspond to the respective array elements.

Parameters:
terms - An array of Term
Returns:
Term a list of the array elements

bindingsToTermArray

public static Term[] bindingsToTermArray(java.util.Map varnames_to_Terms)
Converts a solution hashtable to an array of Terms.

Parameters:
varnames_to_Terms - A Map from variable names to Terms
Returns:
Term[] An array of the Terms to which successive variables are bound

toString

public static java.lang.String toString(java.util.Map varnames_to_Terms)
Converts a substitution, in the form of a Map from variable names to Terms, to a String.

Parameters:
varnames_to_Terms - A Map from variable names to Terms.
Returns:
String A String representation of the variable bindings

namevarsToMap

public static java.util.Map namevarsToMap(Term nvs)
Converts a (JPL) list of Name=Var pairs (as yielded by atom_to_term/3) to a Map from Prolog variables (necessarily in term_t holders) to named JPL Variables

Parameters:
nvs - A JPL list of Name=Var pairs (as yielded by atom_to_term/3)
Returns:
Map A Map from Prolog variables (necessarily in term_t holders) to named JPL Variables

textToTerm

public static Term textToTerm(java.lang.String text)
Converts a Prolog source text to a corresponding JPL Term (in which each Variable has the appropriate name from the source text). Throws PrologException containing error(syntax_error(_),_) if text is invalid.

Parameters:
text - A Prolog source text denoting a term
Returns:
Term a JPL Term equivalent to the given source text