|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectunsw.cse.framescript.Utils
public class Utils
This class provides a number of utility methods for dealing with FrameScript types.
Constructor Summary | |
---|---|
Utils()
|
Method Summary | |
---|---|
static Alternatives |
check_alternatives(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check alternatives arguments for built-in functions. |
static Atom |
check_atom(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check atom arguments for built-in functions. |
static Atom |
check_boolean(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check boolean arguments for built-in functions. |
static Compound |
check_compound(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check compound arguments for built-in functions. |
static Domain |
check_domain(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check domain arguments for built-in functions. |
static ExprList |
check_exprlist(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check expression list arguments for built-in functions. |
static Frame |
check_frame(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check frame arguments for built-in functions. |
static Generic |
check_generic(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check generic frame arguments for built-in functions. |
static Instance |
check_instance(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check instance frame arguments for built-in functions. |
static FSInteger |
check_integer(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check integer arguments for built-in functions. |
static FSList |
check_list(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check list arguments for built-in functions. |
static FSNumber |
check_number(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check numerical arguments for built-in functions. |
static Pattern |
check_pattern(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check pattern arguments for built-in functions. |
static RDR |
check_rdr(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check rdr arguments for built-in functions. |
static Script |
check_script(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check script arguments for built-in functions. |
static Sequence |
check_sequence(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check sequence arguments for built-in functions. |
static FSString |
check_string(java.lang.String functionName,
Instance currentObject,
Term[] arg,
int n,
StackFrame frame)
Convenience routine to check string arguments for built-in functions. |
static java.util.List |
checkAllReferences()
Searches through all terms accessible via the symbol table to check all compounds have an appropriate subr to call when evaluated. |
static void |
closeOutput(java.lang.String filename)
Closes FrameScript's current output stream and pops the last output stream on the output stream stack. |
static java.lang.String |
compress(java.lang.String str)
Compresses a string by replacing whitespace with ' ' and removing multiple spaces. |
static Term |
evaluteStatement(Term statement)
|
static void |
evloop(Parser p,
java.net.URL file)
Reads all the statements available from a Parser and evaluates them. |
static FSException |
FileNotFound(java.lang.String funct,
java.lang.String filename,
java.io.FileNotFoundException e)
Provides a standard mechanism for generating and throwing FSExceptions in response to an FileNotFoundException caught in a subroutine. |
static java.lang.String |
formatComment(java.lang.String comment)
Formats a comment for writing to a file/output stream. |
static java.lang.String |
formatComment(java.lang.String comment,
int indentLevel)
Formats a comment for writing to a file/output stream. |
static java.lang.String |
getMessage(Term t)
Turns a term into a string for displaying. |
static Term |
getName(Term t)
Gets the name of a term if it has one. |
static Pattern |
getPattern(java.lang.String str)
Turns a string into a Pattern so it can be used as an input for a domain. |
static Term |
getValue(Atom atom)
Gets the value for an atom. |
static FSException |
IOError(java.lang.String funct,
java.lang.String filename,
java.io.IOException e)
Provides a standard mechanism for generating and throwing FSExceptions in response to an IOException caught in a subroutine. |
static boolean |
isPattern(Pattern p)
Test if a Pattern could have been read in by a Parser. |
static boolean |
isPatternElement(Term t)
Test if a Term is a pattern element that can be read in by a Parser. |
static boolean |
isUnaryPattern(Term t)
Test if a Term is a Pattern with a single element. |
static void |
loadFile(java.io.File file)
Reads and evaluates FrameScript code from a file. |
static void |
loadFile(java.lang.String fname)
Reads and evaluates FrameScript code from a file. |
static void |
loadFile(java.net.URL file)
Reads FrameScript code from a file retrieved from a given URL. |
static void |
loadModule(java.net.URL classpath,
java.lang.String module)
Loads a FrameScript module into memory. |
static void |
setOutput(java.lang.String filename,
boolean append)
Sets FrameScript's output stream to write to a file. |
static void |
sortAtomList(FSList list)
An in place list sort for lists of Atoms. |
static java.lang.String |
unformatComment(java.lang.String comment)
Removes the formatting for a comment. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static java.lang.String compress(java.lang.String str)
str
- - string being compressed
public static void loadFile(java.lang.String fname) throws FSException
fname
- name of the file to be loaded
FSException
- if the file doesn't exist/can't be readpublic static void loadFile(java.net.URL file) throws FSException
file
- the URL of the file
FSException
- if the file doesn't exist/can't be read or bad syntax in the URLpublic static void loadFile(java.io.File file) throws FSException
file
- the file to be loaded
FSException
- if the file doesn't exist/can't be readpublic static void loadModule(java.net.URL classpath, java.lang.String module) throws FSException
module
- the name of the Module to load
FSException
- if the module doesn't exit/can't be loadedpublic static void setOutput(java.lang.String filename, boolean append) throws java.io.FileNotFoundException
filename
- the name of the file the output is being sent toappend
- whether or not to append output to the file
java.io.FileNotFoundException
public static void closeOutput(java.lang.String filename)
filename
- the name of the file to be closed, if the current output stream
isn't associated with the file it does nothing. If null then it closes the current
output stream no matter which file it is going to.public static void evloop(Parser p, java.net.URL file) throws java.io.IOException
p
- the Parser which generates the statements for evaluationfile
- the url of the file associated with the Parser, if null it
is assumed that the parser uses System.in
java.io.IOException
public static Term evaluteStatement(Term statement) throws FSException
FSException
public static Alternatives check_alternatives(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the alternatives isn't an atom
FSException
public static Atom check_atom(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't an atom
FSException
public static Atom check_boolean(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a boolean
FSException
public static Compound check_compound(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a compound
FSException
public static Domain check_domain(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguments to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a domain
FSException
public static ExprList check_exprlist(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a framen expression list
FSException
public static Frame check_frame(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a frame
FSException
public static Generic check_generic(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a generic frame
FSException
public static Instance check_instance(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't an instance frame
FSException
public static FSInteger check_integer(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't an integer
FSException
public static FSList check_list(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a list
FSException
public static FSNumber check_number(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a number
FSException
public static Pattern check_pattern(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a pattern
FSException
public static RDR check_rdr(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a rdr
FSException
public static Script check_script(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a script
FSException
public static Sequence check_sequence(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a sequence
FSException
public static FSString check_string(java.lang.String functionName, Instance currentObject, Term[] arg, int n, StackFrame frame) throws FSException
functionName
- name of the function calling the routinecurrentObject
- the current enclosing instance framearg
- the arguements to the functionn
- the index of the argument being checkedframe
- a StackFrame containing contextual information
FRSerror
- if the argument isn't a string
FSException
public static java.lang.String getMessage(Term t)
t
- term to be turned into a string
public static Term getName(Term t)
t
- the Term whose name to get
public static Term getValue(Atom atom)
atom
- the atom whose value is required
public static Pattern getPattern(java.lang.String str) throws SyntaxError, java.io.IOException
str
- the string to parse as a Pattern
SyntaxError
java.io.IOException
public static void sortAtomList(FSList list)
list
- the list of Atomspublic static FSException IOError(java.lang.String funct, java.lang.String filename, java.io.IOException e) throws FSException
funct
- name of the subroutine that caught the IOExceptionfilename
- name of the file that threw the IOExceptione
- the IOException
FSException
public static FSException FileNotFound(java.lang.String funct, java.lang.String filename, java.io.FileNotFoundException e) throws FSException
funct
- name of the subroutine that caught the IOExceptionfilename
- name of the file that threw the IOExceptione
- the IOException
FSException
public static boolean isPattern(Pattern p)
p
- Pattern being tested
public static boolean isUnaryPattern(Term t)
t
- Term to be tested
public static boolean isPatternElement(Term t)
t
- Term to be tested
public static java.lang.String formatComment(java.lang.String comment)
comment
- the comment to be formatted
public static java.lang.String formatComment(java.lang.String comment, int indentLevel)
comment
- the comment to be formattedindentLevel
- the indentation level to use in formatting the comment
public static java.lang.String unformatComment(java.lang.String comment)
comment
- the comment whose formatting is to be removed
public static java.util.List checkAllReferences()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |