com.sri.oaa2.icl
Class IclUtils

java.lang.Object
  |
  +--com.sri.oaa2.icl.IclUtils

public class IclUtils
extends java.lang.Object


Field Summary
static IclTerm iclTrue
          Deprecated. use getTrueAtom()
 
Constructor Summary
IclUtils()
           
 
Method Summary
static void debugP(java.lang.String s)
           
static void debugPrint(java.lang.String s)
          debugPrint
static void debugPrint(java.lang.String s, IclTerm t)
          debugPrint
static java.lang.String doubleQuotes(java.lang.String s)
          Doubles any "'" in the string, to prepare the string to be surrounded by "'".
static java.lang.String fixQuotes(java.lang.String s)
          Converts any '' marks inside a string to just ', and removes any external quote marks around the string.
static IclTerm fromString(boolean failFast, java.lang.String t)
          Generate an IclTerm from a string, throwing RuntimeException on errors, or displaying the errors.
static IclTerm fromString(java.lang.String t)
          Generate an IclTerm from a string.
static IclTerm getMember(IclTerm elt, IclTerm list)
          Get an element in the list which unifies with the given elt..
static IclTerm getParamValue(java.lang.String functor, IclTerm defaultVal, IclList params)
          Get a parameter value from a parameter list, using the default if the parameter if the given functor isn't in the list.
static IclTerm getTrueAtom()
          Get the atom representing "true"
static IclTerm icl(java.lang.String t)
          Deprecated. use IclTerm.fromString(String) (which throws exceptions). You can also use fromString(bolean, String) if you want a runtime exception.
static boolean iclIsEmptyList(IclTerm in)
          Deprecated. use IclTerm.isEmptyList
static boolean iclIsFloat(IclTerm in)
          Deprecated. use IclTerm.isFloat
static boolean iclIsGroup(IclTerm in)
          Deprecated. use IclTerm.isGroup
static boolean iclIsInt(IclTerm in)
          Deprecated. use IclTerm.isInt
static boolean iclIsList(IclTerm in)
          Deprecated. use IclTerm.isList
static boolean iclIsStr(IclTerm in)
          Deprecated. use IclTerm.isStr
static boolean iclIsStruct(IclTerm in)
          Deprecated. use IclTerm.isStruct
static boolean iclIsValid(IclTerm in)
          Deprecated. silly--will always return true
static boolean iclIsVar(IclTerm in)
          Deprecated. use IclTerm.isVar
static IclTerm iclMember(IclTerm elt, IclTerm list)
          Deprecated. use getMember
static IclTerm iclNewTermFromString(java.lang.String t)
          Deprecated. use IclTerm.fromString()
static IclTerm iclParamValue(java.lang.String function, IclTerm paramList)
          Deprecated. use termParamValue().getTerm(0) or getParamValue()
static IclTerm iclParamValue(java.lang.String function, IclTerm match, IclTerm paramList)
          Deprecated. use termParamValue
static int iclParamValueAsInt(java.lang.String func, IclTerm paramList)
          Deprecated. use intParamValue()
static int intParamValue(java.lang.String func, IclTerm paramList)
          As termParamValue, but uses null for the expectedValue, and attempts to convert the IclTerm to an int.
static int intParamValue(java.lang.String func, int defaultValue, IclTerm paramList)
          As termParamValue, but uses null for the expectedValue, and attempts to convert the IclTerm to an int.
static boolean removeParamValue(java.lang.String functor, IclList params)
          Removes all occurences of a functor from a parameter list.
static java.lang.String removeQuotes(java.lang.String s)
          Remove the quotes from a string.
static IclTerm termParamValue(java.lang.String key, IclTerm expectedValue, IclTerm paramList)
          Get a parameter value from a list.
static java.lang.String undoubleQuotes(java.lang.String s)
          Converts any '' marks inside a string to just '.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iclTrue

public static final IclTerm iclTrue
Deprecated. use getTrueAtom()

Constructor Detail

IclUtils

public IclUtils()
Method Detail

getTrueAtom

public static IclTerm getTrueAtom()
Get the atom representing "true"


icl

public static IclTerm icl(java.lang.String t)
Deprecated. use IclTerm.fromString(String) (which throws exceptions). You can also use fromString(bolean, String) if you want a runtime exception.


fromString

public static IclTerm fromString(boolean failFast,
                                 java.lang.String t)
Generate an IclTerm from a string, throwing RuntimeException on errors, or displaying the errors.

Returns:
IclTerm: the new IclTerm or null if it could not be parsed

fromString

public static IclTerm fromString(java.lang.String t)
                          throws antlr_oaa.RecognitionException,
                                 antlr_oaa.TokenStreamException
Generate an IclTerm from a string. Thread safe. See IclTerm.fromString for actual implementation.

Returns:
IclTerm: the new IclTerm or null if it could not be parsed
Throws:
antlr_oaa.RecognitionException - if the string could not be parsed
antlr_oaa.TokenStreamException - if the string could not be tokenized

removeParamValue

public static boolean removeParamValue(java.lang.String functor,
                                       IclList params)
Removes all occurences of a functor from a parameter list.

Parameters:
functor - the functor to remove
params - the parameter list
Returns:
true if one or more functors were removed from the parameter list, and false if the input functor was not found in the parameter list.

getParamValue

public static IclTerm getParamValue(java.lang.String functor,
                                    IclTerm defaultVal,
                                    IclList params)
Get a parameter value from a parameter list, using the default if the parameter if the given functor isn't in the list.

Returns:
IclTerm the desired parameter value, or the default

termParamValue

public static IclTerm termParamValue(java.lang.String key,
                                     IclTerm expectedValue,
                                     IclTerm paramList)
Get a parameter value from a list. A parameter list looks like: [key1(value1),key2(value2),...,keyn(valuen)]. This looks for the parameter with key as given. If expectedValue is not null, then it also looks for the parameter that unifies with the given value. If it is null, then we just look for any parameter with the given key. If multiple matching parameters exist, this returns the first one.

Returns:
IclTerm: the found parameter as key(value), or null

intParamValue

public static int intParamValue(java.lang.String func,
                                int defaultValue,
                                IclTerm paramList)
As termParamValue, but uses null for the expectedValue, and attempts to convert the IclTerm to an int.

Throws:
RuntimeException: - if the returned parameter cannot be converted.

intParamValue

public static int intParamValue(java.lang.String func,
                                IclTerm paramList)
As termParamValue, but uses null for the expectedValue, and attempts to convert the IclTerm to an int.

Throws:
RuntimeException: - if the returned parameter cannot be converted.

getMember

public static IclTerm getMember(IclTerm elt,
                                IclTerm list)
Get an element in the list which unifies with the given elt.. Note that list *must* be an IclList.


undoubleQuotes

public static java.lang.String undoubleQuotes(java.lang.String s)
Converts any '' marks inside a string to just '. Single quotes inside strings will be doubled when coming from Prolog.

Parameters:
s - the string to undouble quotes
Returns:
the input string with double quotes converted to single quotes
See Also:
removeQuotes(java.lang.String), fixQuotes(java.lang.String)

doubleQuotes

public static java.lang.String doubleQuotes(java.lang.String s)
Doubles any "'" in the string, to prepare the string to be surrounded by "'".

Parameters:
s - the string to convert to double quotes
Returns:
the input string with quotes doubled.
See Also:
undoubleQuotes(java.lang.String), fixQuotes(java.lang.String)

removeQuotes

public static java.lang.String removeQuotes(java.lang.String s)
Remove the quotes from a string.

Parameters:
s - the string ro remove quotes from
Returns:
the original string without surrounding quotes

fixQuotes

public static java.lang.String fixQuotes(java.lang.String s)
Converts any '' marks inside a string to just ', and removes any external quote marks around the string. (Calls removeQuotes, followed by undoubleQuotes).

Parameters:
s - the string to fix quotes
Returns:
the string with quotes fixed
See Also:
removeQuotes(java.lang.String), undoubleQuotes(java.lang.String)

iclParamValueAsInt

public static int iclParamValueAsInt(java.lang.String func,
                                     IclTerm paramList)
Deprecated. use intParamValue()


iclParamValue

public static IclTerm iclParamValue(java.lang.String function,
                                    IclTerm match,
                                    IclTerm paramList)
Deprecated. use termParamValue


iclParamValue

public static IclTerm iclParamValue(java.lang.String function,
                                    IclTerm paramList)
Deprecated. use termParamValue().getTerm(0) or getParamValue()


iclMember

public static IclTerm iclMember(IclTerm elt,
                                IclTerm list)
Deprecated. use getMember


iclNewTermFromString

public static IclTerm iclNewTermFromString(java.lang.String t)
Deprecated. use IclTerm.fromString()


iclIsList

public static boolean iclIsList(IclTerm in)
Deprecated. use IclTerm.isList


iclIsInt

public static boolean iclIsInt(IclTerm in)
Deprecated. use IclTerm.isInt


iclIsFloat

public static boolean iclIsFloat(IclTerm in)
Deprecated. use IclTerm.isFloat


iclIsStruct

public static boolean iclIsStruct(IclTerm in)
Deprecated. use IclTerm.isStruct


iclIsVar

public static boolean iclIsVar(IclTerm in)
Deprecated. use IclTerm.isVar


iclIsGroup

public static boolean iclIsGroup(IclTerm in)
Deprecated. use IclTerm.isGroup


iclIsStr

public static boolean iclIsStr(IclTerm in)
Deprecated. use IclTerm.isStr


iclIsEmptyList

public static boolean iclIsEmptyList(IclTerm in)
Deprecated. use IclTerm.isEmptyList


iclIsValid

public static boolean iclIsValid(IclTerm in)
Deprecated. silly--will always return true


debugP

public static void debugP(java.lang.String s)

debugPrint

public static void debugPrint(java.lang.String s,
                              IclTerm t)
debugPrint


debugPrint

public static void debugPrint(java.lang.String s)
debugPrint