org.jpl7

## Class Util

- java.lang.Object
- - org.jpl7.Util

-     public final class Util
      extends java.lang.Object

  This class provides a bunch of static utility methods to support JPL's Java API.

  Copyright (C) 2004 Paul Singleton

  Copyright (C) 1998 Fred Dushin

  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Util()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String[]` | `atomListToStringArray(Term t)` Deprecated. Use `Term.atomListToStringArray(Term)`
    `static Term` | `intArrayArrayToList(int[][] a)` Deprecated. Use `Term.intArrayArrayToList(int[][] a)`
    `static Term` | `intArrayToList(int[] a)` Deprecated. Use `Term.intArrayToList(int[] a)`
    `static boolean` | `isList(Term term)` Deprecated. Use `Term.isList(Term)`
    `static int` | `listToLength(Term term)` Deprecated. Use `Term.listLength(Term)`
    `static Term[]` | `listToTermArray(Term t)` Deprecated. Use `Term.listToTermArray(Term)`
    `static java.util.Map<term_t,Variable>` | `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` | `stringArrayToList(java.lang.String[] a)` Deprecated. Use `Term.stringArrayToList(String[] a)`
    `static java.lang.String` | `subsToString(java.util.Map<java.lang.String,Term> varnames_to_Terms)` Converts a substitution, in the form of a Map from variable names to Terms, to a String.
    `static Term` | `termArrayToList(Term[] terms)` Deprecated. Use `Term.termArrayToList(Term[] terms)`
    `static Term` | `textParamsToTerm(java.lang.String text, Term[] params)` Converts a Prolog source text to a corresponding JPL Term (in which each Variable has the appropriate name from the source text), replacing successive occurrences of ? in the text by the corresponding element of Term[] params.
    `static Term` | `textToTerm(java.lang.String text)` Deprecated. Use `Term.textToTerm(String text)`
    `static java.lang.String` | `toString(java.util.Map<java.lang.String,Term> varnames_to_Terms)` Deprecated. Use `subsToString(Map)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Util

          public Util()

  - ### Method Detail

    - #### termArrayToList

          @Deprecated
          public static Term termArrayToList(Term[] terms)

      Deprecated. Use `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

    - #### subsToString

          public static java.lang.String subsToString(java.util.Map<java.lang.String,Term> 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

    - #### toString

          @Deprecated
          public static java.lang.String toString(java.util.Map<java.lang.String,Term> varnames_to_Terms)

      Deprecated. Use `subsToString(Map)`

    - #### namevarsToMap

          public static java.util.Map<term_t,Variable> 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

          @Deprecated
          public static Term textToTerm(java.lang.String text)

      Deprecated. Use `Term.textToTerm(String text)`

    - #### textParamsToTerm

          public static Term textParamsToTerm(java.lang.String text,
                                              Term[] params)

      Converts a Prolog source text to a corresponding JPL Term (in which each Variable has the appropriate name from the source text), replacing successive occurrences of ? in the text by the corresponding element of Term[] params. (New in JPL 3.0.4) Throws PrologException containing error(syntax_error(_),_) if text is invalid.
      Parameters:
        `text` - A Prolog source text denoting a term
        `params` - parameters to be injected in each ?
      Returns:
        Term a JPL Term equivalent to the given source text

    - #### stringArrayToList

          @Deprecated
          public static Term stringArrayToList(java.lang.String[] a)

      Deprecated. Use `Term.stringArrayToList(String[] a)`

    - #### intArrayToList

          @Deprecated
          public static Term intArrayToList(int[] a)

      Deprecated. Use `Term.intArrayToList(int[] a)`

    - #### intArrayArrayToList

          @Deprecated
          public static Term intArrayArrayToList(int[][] a)

      Deprecated. Use `Term.intArrayArrayToList(int[][] a)`

    - #### isList

          @Deprecated
          public static final boolean isList(Term term)

      Deprecated. Use `Term.isList(Term)`
      Parameters:
        `term` - a term
      Returns:
        if term is a proper list

    - #### listToLength

          @Deprecated
          public static int listToLength(Term term)

      Deprecated. Use `Term.listLength(Term)`
      Parameters:
        `term` - any Term
      Returns:
        the length of the proper list which the Term represents, else -1

    - #### listToTermArray

          @Deprecated
          public static Term[] listToTermArray(Term t)

      Deprecated. Use `Term.listToTermArray(Term)`
      Builds a Java array of Terms from a a list of terms (as a Compound)
      Parameters:
        `t` - a compound term that is a list
      Returns:
        an array of terms, one per element in the list

    - #### atomListToStringArray

          @Deprecated
          public static java.lang.String[] atomListToStringArray(Term t)

      Deprecated. Use `Term.atomListToStringArray(Term)`
      Parameters:
        `t` - a compound term that is a list of atoms
      Returns:
        a String array representing the list of atoms