se.chalmers.cs.gf.dialogutil
Class IclUtil

java.lang.Object
  extended by se.chalmers.cs.gf.dialogutil.IclUtil

public class IclUtil
extends java.lang.Object

Some general ICL utilities.


Method Summary
static com.sri.oaa2.icl.IclTerm firstMatch(com.sri.oaa2.icl.IclTerm t, com.sri.oaa2.icl.IclList l)
          Get the first term from a list which unifies with a given term.
static com.sri.oaa2.icl.IclList fromList(java.util.List<com.sri.oaa2.icl.IclTerm> l)
          Convert a list of IclTerms to an IclList.
static java.lang.String fromStr(com.sri.oaa2.icl.IclTerm t)
          Gets the string value of an ICL string.
static com.sri.oaa2.icl.IclTerm icl(java.lang.String s)
          Convert a string to an IclTerm.
static com.sri.oaa2.icl.IclTerm matchAndGetVar(com.sri.oaa2.icl.IclTerm t1, com.sri.oaa2.icl.IclTerm t2, java.lang.String var)
          Unify two terms and get the value of a variable bound by the unifications.
static java.util.Map<java.lang.String,com.sri.oaa2.icl.IclTerm> matchAndGetVars(com.sri.oaa2.icl.IclTerm t1, com.sri.oaa2.icl.IclTerm t2)
          Unify two terms and get the values of all variable bound by the unifications.
static com.sri.oaa2.icl.IclTerm matchInListAndGetVar(com.sri.oaa2.icl.IclTerm t, com.sri.oaa2.icl.IclList l, java.lang.String var)
          Try unifying a term which each element in a list.
static java.util.List<com.sri.oaa2.icl.IclTerm> toList(com.sri.oaa2.icl.IclList l)
          Convert an IclList to a list of IclTerms.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

matchAndGetVar

public static com.sri.oaa2.icl.IclTerm matchAndGetVar(com.sri.oaa2.icl.IclTerm t1,
                                                      com.sri.oaa2.icl.IclTerm t2,
                                                      java.lang.String var)
Unify two terms and get the value of a variable bound by the unifications.

Returns:
The value of var, or null if the unification failed or did not bind var.

matchAndGetVars

public static java.util.Map<java.lang.String,com.sri.oaa2.icl.IclTerm> matchAndGetVars(com.sri.oaa2.icl.IclTerm t1,
                                                                                       com.sri.oaa2.icl.IclTerm t2)
Unify two terms and get the values of all variable bound by the unifications.

Returns:
A map of variable names to values, or null if the unification failed.

matchInListAndGetVar

public static com.sri.oaa2.icl.IclTerm matchInListAndGetVar(com.sri.oaa2.icl.IclTerm t,
                                                            com.sri.oaa2.icl.IclList l,
                                                            java.lang.String var)
Try unifying a term which each element in a list. For the the first term that unifies, return the value of a variable bound by the unification.


firstMatch

public static com.sri.oaa2.icl.IclTerm firstMatch(com.sri.oaa2.icl.IclTerm t,
                                                  com.sri.oaa2.icl.IclList l)
Get the first term from a list which unifies with a given term.


icl

public static com.sri.oaa2.icl.IclTerm icl(java.lang.String s)
Convert a string to an IclTerm.


toList

public static java.util.List<com.sri.oaa2.icl.IclTerm> toList(com.sri.oaa2.icl.IclList l)
Convert an IclList to a list of IclTerms.


fromList

public static com.sri.oaa2.icl.IclList fromList(java.util.List<com.sri.oaa2.icl.IclTerm> l)
Convert a list of IclTerms to an IclList.


fromStr

public static java.lang.String fromStr(com.sri.oaa2.icl.IclTerm t)
Gets the string value of an ICL string.

Throws:
java.lang.ClassCastException - if the term is not a string.