jess.xml
Class XMLPrinter

java.lang.Object
  extended by jess.xml.XMLPrinter
All Implemented Interfaces:
java.io.Serializable

public class XMLPrinter
extends java.lang.Object
implements java.io.Serializable

This class can translate a whole file of Jess code into JessML. You can construct an XMLPrinter that will send its output to a given Writer objects, then use the other methods of the class to write an XML prelude and trailer surrounding an arbitrary amount of JessML code translated directly from Jess code.

This class includes a main() method that reads from a file and emits a complete JessML document on standard output.

(C) 2013 Sandia Corporation

See Also:
Serialized Form

Constructor Summary
XMLPrinter(java.io.Writer writer)
          Constructor.
 
Method Summary
 void close()
          Closes the underlying Writer.
static void main(java.lang.String[] args)
          Reads a file of Jess code and emits equivalent XML on standard output, as a complete, well-formed JessML document.
 void printBackMatter()
          Prints a closing "rulebase" tag to the underlying writer.
 void printFrontMatter()
          Prints an XML prelude, JessML version instruction, and opening "rulebase" tag to the underlying writer.
 void translateToXML(java.io.Reader reader)
          Reads Jess code from the Reader, and sends JessML equivalents to the underlying Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLPrinter

public XMLPrinter(java.io.Writer writer)
Constructor. Creates an XMLPrinter that sends its output to the given Writer.

Parameters:
writer - the writer to send output to
Method Detail

close

public void close()
           throws java.io.IOException
Closes the underlying Writer.

Throws:
java.io.IOException - if calling close() on the Writer throws it

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        JessException
Reads a file of Jess code and emits equivalent XML on standard output, as a complete, well-formed JessML document. Calls printFrontMatter(), translateToXML(), and printBackMatter(), in that order.

Parameters:
args - first argument is the path to a file of Jess code
Throws:
java.io.IOException - if the file doesn't exist
JessException - if anything goes wrong

translateToXML

public void translateToXML(java.io.Reader reader)
                    throws JessException
Reads Jess code from the Reader, and sends JessML equivalents to the underlying Writer. No XML header or footer are written -- just the individual constructs.

Parameters:
reader - a source of Jess code
Throws:
JessException - if anything goes wrong

printBackMatter

public void printBackMatter()
                     throws java.io.IOException
Prints a closing "rulebase" tag to the underlying writer.

Throws:
java.io.IOException - if anything goes wrong

printFrontMatter

public void printFrontMatter()
                      throws java.io.IOException
Prints an XML prelude, JessML version instruction, and opening "rulebase" tag to the underlying writer.

Throws:
java.io.IOException - if anything goes wrong

2013 Sandia Corporation