jess
Class Batch

java.lang.Object
  extended by jess.Batch
All Implemented Interfaces:
java.io.Serializable, Userfunction

public class Batch
extends java.lang.Object
implements Userfunction, java.io.Serializable

This class implements the "batch" command, and several static methods are available that you can call to load Jess code.

(C) 2007 Sandia National Laboratories

See Also:
Rete.batch(java.lang.String), Serialized Form

Constructor Summary
Batch()
           
 
Method Summary
static Value batch(java.io.Reader reader, Rete engine, Context context, ErrorHandler handler)
           
static Value batch(java.lang.String filename, Rete engine)
          Execute a file of Jess code, either in the Jess rule language or in JessML.
static Value batch(java.lang.String filename, Rete engine, Context context)
          Execute a file of Jess code, either in the Jess rule language or in JessML.
static Value batch(java.lang.String filename, Rete engine, Context context, ErrorHandler handler)
          Execute a file of Jess code, either in the Jess rule language or in JessML.
static Value batch(java.lang.String filename, java.lang.String charset, Rete engine)
          Execute a file of Jess code, either in the Jess rule language or in JessML.
static Value batch(java.lang.String filename, java.lang.String charset, Rete engine, Context context)
          Execute a file of Jess code, either in the Jess rule language or in JessML.
static Value batch(java.lang.String filename, java.lang.String charset, Rete engine, Context context, ErrorHandler handler)
           
 Value call(ValueVector vv, Context context)
          The implementation of the Jess language "batch" command, which just calls batch(java.lang.String, jess.Rete).
static java.io.PushbackReader findDocument(Rete engine, java.lang.String filename)
          Searches for the named file of Jess code, opens it if found and returns a Reader for the data.
static java.io.PushbackReader findDocument(Rete engine, java.lang.String filename, java.lang.String charset)
          Searches for the named file of Jess code, opens it if found and returns a Reader for the data.
 java.lang.String getName()
          Return the name of this function.
static boolean isXMLDocument(java.io.PushbackReader fis)
          Returns true if the first character of the file is a "<", so that it's possible the file contains XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Batch

public Batch()
Method Detail

getName

public java.lang.String getName()
Description copied from interface: Userfunction
Return the name of this function. Called once when the function is installed into a Rete engine.

Specified by:
getName in interface Userfunction
Returns:
The name of this function, as seen by the Jess language

batch

public static Value batch(java.lang.String filename,
                          Rete engine)
                   throws JessException
Execute a file of Jess code, either in the Jess rule language or in JessML. The filename will be looked for first on the file system; if it's not found, Jess will search the classpath. If Jess is used in an Applet, the applet's document base will be checked first. The code will be evaluated in the Rete object's global execution context. Any errors will terminate parsing.

Parameters:
filename - the name of a file, or a relative or absolute path
engine - the Rete object to load with the constructs from the file
Returns:
the last expression parsed
Throws:
JessException - if anything goes wrong

batch

public static Value batch(java.lang.String filename,
                          java.lang.String charset,
                          Rete engine)
                   throws JessException
Execute a file of Jess code, either in the Jess rule language or in JessML. The filename will be looked for first on the file system; if it's not found, Jess will search the classpath. If Jess is used in an Applet, the applet's document base will be checked first. The code will be evaluated in the Rete object's global execution context. Any errors will terminate parsing. You must specify the name of the charset to use.

Parameters:
filename - the name of a file, or a relative or absolute path
charset - the name of the character set to use in interpreting the file
engine - the Rete object to load with the constructs from the file
Returns:
the last expression parsed
Throws:
JessException - if anything goes wrong

batch

public static Value batch(java.lang.String filename,
                          Rete engine,
                          Context context)
                   throws JessException
Execute a file of Jess code, either in the Jess rule language or in JessML. The filename will be looked for first on the file system; if it's not found, Jess will search the classpath. If Jess is used in an Applet, the applet's document base will be checked first. The code will be evaluated in the given execution context. Any errors will terminate parsing.

Parameters:
filename - the name of a file, or a relative or absolute path
engine - the Rete object to load with the constructs from the file
context - the execution context to use
Returns:
the last expression parsed
Throws:
JessException - if anything goes wrong

batch

public static Value batch(java.lang.String filename,
                          java.lang.String charset,
                          Rete engine,
                          Context context)
                   throws JessException
Execute a file of Jess code, either in the Jess rule language or in JessML. The filename will be looked for first on the file system; if it's not found, Jess will search the classpath. If Jess is used in an Applet, the applet's document base will be checked first. The code will be evaluated in the given execution context. Any errors will terminate parsing.

Parameters:
filename - the name of a file, or a relative or absolute path
charset - the name of the character set to use in interpreting the file
engine - the Rete object to load with the constructs from the file
context - the execution context to use
Returns:
the last expression parsed
Throws:
JessException - if anything goes wrong

batch

public static Value batch(java.lang.String filename,
                          Rete engine,
                          Context context,
                          ErrorHandler handler)
                   throws JessException
Execute a file of Jess code, either in the Jess rule language or in JessML. The filename will be looked for first on the file system; if it's not found, Jess will search the classpath. If Jess is used in an Applet, the applet's document base will be checked first. The code will be evaluated in the given execution context. If any errors are encountered, the given error handler will be invoked. If the error handler rethrows the exception, parsing will terminate; otherwise parsing will continue.

Parameters:
filename - the name of a file, or a relative or absolute path
engine - the Rete object to load with the constructs from the file
context - the execution context to use
handler - notified in case of exceptions
Returns:
the last expression parsed
Throws:
JessException - if anything goes wrong
See Also:
ErrorHandler

batch

public static Value batch(java.lang.String filename,
                          java.lang.String charset,
                          Rete engine,
                          Context context,
                          ErrorHandler handler)
                   throws JessException
Throws:
JessException

batch

public static Value batch(java.io.Reader reader,
                          Rete engine,
                          Context context,
                          ErrorHandler handler)
                   throws JessException
Throws:
JessException

findDocument

public static java.io.PushbackReader findDocument(Rete engine,
                                                  java.lang.String filename)
                                           throws JessException,
                                                  java.io.IOException
Searches for the named file of Jess code, opens it if found and returns a Reader for the data. This method implements the algorithm used by batch and by Main to find named source code files.

If Jess is running in an applet, this method will look for the named file at the applet's document base.

If not in an applet, the method will first assume the argument is a relative path on the local file system.

If the file does not exist, Jess will attempt to use Rete.getResource(String) to find the file.

Failing that, the method will throw an exception. Uses the platform default character set.

Parameters:
engine - the active rule engine
filename - the path to a file of Jess code
Returns:
an open Reader to return the file's data
Throws:
JessException - if all attempts to find the file fail
java.io.IOException - if the file is found but an error occurs on opening it

findDocument

public static java.io.PushbackReader findDocument(Rete engine,
                                                  java.lang.String filename,
                                                  java.lang.String charset)
                                           throws JessException,
                                                  java.io.IOException
Searches for the named file of Jess code, opens it if found and returns a Reader for the data. This method implements the algorithm used by batch and by Main to find named source code files.

If Jess is running in an applet, this method will look for the named file at the applet's document base.

If not in an applet, the method will first assume the argument is a relative path on the local file system.

If the file does not exist, Jess will attempt to use Rete.getResource(String) to find the file.

Failing that, the method will throw an exception.

Parameters:
engine - the active rule engine
filename - the path to a file of Jess code
charset - the name of the character set used in the file
Returns:
an open Reader to return the file's data
Throws:
JessException - if all attempts to find the file fail
java.io.IOException - if the file is found but an error occurs on opening it

isXMLDocument

public static boolean isXMLDocument(java.io.PushbackReader fis)
                             throws java.io.IOException
Returns true if the first character of the file is a "<", so that it's possible the file contains XML. Such a file can't be Jess code.

Parameters:
fis - the open file
Returns:
true if the file looks like XML rather than Jess code
Throws:
java.io.IOException - if anything goes wrong

call

public Value call(ValueVector vv,
                  Context context)
           throws JessException
The implementation of the Jess language "batch" command, which just calls batch(java.lang.String, jess.Rete).

Specified by:
call in interface Userfunction
Parameters:
vv - the function call
context - the execution context
Returns:
the last expression parsed
Throws:
JessException - if anything goes wrong
See Also:
Value.resolveValue(jess.Context)

2013 Sandia Corporation