|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
MathPrinter | This interface describes the mechanism by which the MathTools classes communicate with external applications. |
MathToolsAccessory | This is a generic interface for a MathTools accessory class. |
MAuthenticator | This interface specifies a generic way to authenticate at three levels: student, proctor, and instructor. |
Class Summary | |
---|---|
BasicMathPrinter | This class provides a MathPrinter implementation with all required methods and several extension points. |
CCLogErrorManager | This class is designed to complement CCLogHandler . |
CCLogHandler | This class allows the java.util.logging framework to be attached to the MathTools logging methods. |
MathConsole | This class exists to provide scripting languages access to the MathTools logging framework and Global Pizza. |
MathDBC | This class provides MathTools access to JDBC-compliant databases. |
MathFileIO | This class provides MathTools with file IO capability. |
MMatrixBuilder | This is a helper method for creating MMatrices. |
MTApplet | This Applet is designed to allow MathTools scripting via a web browser and to act as CapCom's MathPrinter on an (X)HTML page. |
MTXErrorHandler | This class extends org.xml.sax.helpers.DefaultHandler and implements javax.xml.transform.ErrorListener Its sole reason for existence
is to report XML errors. |
MTXProcessor | The MathTools XML Processor processes the XML tags generated by the MathTools classes with a toXML() method. |
NoteworthyParser | This class is designed to take a Noteworthy-formatted document and convert it to HTML. |
QuickRPNCalculator | This class presents a quick and easy GUI for the MathEngine parseRPN() method. |
SimpleAuthenticator | This class provides a fully-functional MAuthenticator implementation. |
The util package provides help and support to the core MathTools classes. They also provide bridges between MathTools and scripts, web pages, or other applications. Some of these classes are useful (and used) by one or more core classes while others provide access to the core tools.
The MathPrinter interface provides a way to receive data and information from MathTools classes. It provides a simple logging framework usable as such by any application with simple requirements, or easily adapted to applications with more advanced logging needs. The interface itself provides a mathLog() method, a mathPrintln() method, and a processMathObject() method.
The mathLog() method provides logging. MathPrinter defines and uses three levels: debug, info, and error. Debug is useful for working out problems in program flow and execution. Info is just that: information that is good to know but not critical for working out bugs or reporting program errors. Error level is for serious conditions that might corrupt program output or threaten execution. CapCom provides two static convenience methods for each level: level(String) and level(String, Throwable). These methods reflect to CapCom's mathLog() method with the appropriate level constant supplied.
The mathPrintln() method provides a way to communicate with an application outside the logging framework. The metaphor used is that of a console with some type of display area upon which can be printed things. The core MathTools packages do not use this method but the demo classes do.
The processMathObject() method is provided solely as an extension point; none of the core MathTools classes use it. It accepts an Object as a parameter and
returns an Object. How an application handles this is entirely up to the application. This method was designed as an anonymous generic method for communicating
between an application and a script. (NOTE: Although none of the core tools use this method, BasicMathPrinter
defines it and uses it to provide
access to the clipboard. Several of the demonstration classes do use this!)
CapCom communicates with applications via the Global Printer. The CapCom.setPrinter() method is used to set a MathPrinter for classes, scripts, or applications to use. If a Global Printer is set, it receives ALL mathLog(), mathPrintln() and processMathObject() calls. If no printer is set, these calls are silently ignored. Ideally, an application using MathTools should implement MathPrinter and set itself as THE global printer.
BasicMathPrinter (BMP) is a GUI-ready MathPrinter implementation. It provides sufficient functionality to meet MathTools logging and communication needs plus
provides extension points for easy customization. The default implementation provides clipboard access via the processMathObject()
method.
Structurally BasicMathPrinter provides a TextArea 'console' which receives all mathPrintln() and logging messages. It has a Checkbox for each log level, an extra Checkbox to enable/disable stack trace printing, a Checkbox to enable the clipboard, and a button to clear the 'screen.'
The main extension point is BMP's [Go!] button. It connects to the processGoButton() method which is basically empty. The default implementation checks each log level and prints a sample stack trace. Overriding this method provides a pre-built place to execute code without the rigors of constructing a custom GUI. BMP uses a BorderLayout with two locations empty, so extra GUI elements can be added as needed.
MathConsole provides scripts with access to CapCom's logging, print, and processing machinery. It does not and should not implement the MathPrinter interface, rather, it provides the front end for one. Java classes implementing MathPrinter and becoming the Global Printer can override the processMathObject() method and use the MathConsole to give scripts access to it.
The Global Pizza is a java.util.Properties object settable and gettable via CapCom. It is primarily meant for supplying parameters to scripts in an easily-accessible way. Scripts can access the Global Pizza and CapCom's Shelf via the MathConsole installed as a Standard Object.
This class provides a way to link java.util.logging
with MathTools' logging framework. The class extends java.util.logging.Handler
and provides a Handler
instance that will fit Java logging messages into the MathPrinter
levels. SEVERE and WARNING map to Error
level, INFO maps to Info and CONFIG or less all map to Debug level. This mapping is done numerically so that any custom logging levels that conform to the
Java logging package will integrate seamlessly.
To accomplish this task simply create or obtain a suitable java.util.logging.Logger
instance, create a CCLogHandler
and add it to
the Logger
. The only methods defined are flush()
(empty), close()
(almost empty), isLoggable()
and, of
course, publish
. The close()
method clears out any internal java.util.Formatter
instances.
The isLoggable()
method checks to see if a Global MathPrinter is set. If not it returns 'false' immediately, if so it returns the result of
super.isLoggable()
. The publish()
method only refuses if no Global Printer is set, otherwise it publishes the message.
This is the complementary class to CCLogHandler
. It allows errors generated by the logging system to be reported through CapCom. This behavior
is built into CCLogHandler
so an external error manager is not needed but can, of course, be added if desired. Methods on both classes allow
exact configuration of both application and log-system error management.
MTApplet exists to provide web browsers access to MathTools. MathTools was not designed for web apps, but HTML documents are one of the most common vehicles for scripting. This is especially true of Firefox and browsers based on it. MTApplet can, if embedded in an HTML document, create instances of all core MathTools classes.
MTApplet itself implements MathPrinter and it has a method to set itself as the Global Printer. This plus a MathConsole provides scripts with an easy way to print text, without pesky alert() boxes or tiny status lines. The GUI is similar to BasicMathPrinter's, with a TextArea 'console,' a [Clear] button and Checkboxes to filter log levels and stack traces.
This class is specifically designed to create double[][] arrays and MMatrices. It has methods to turn various formats of Strings or String[] arrays into either double[][] arrays or straight into MMatrices. It can create and fill arrays to specification, create specialty arrays (e.g. Square), and turn a 'ragged' array into one with rows of equal length. It also has several debugging methods to dump arrays and print information about MMatrices.
QuickRPNCalculator is a ready-made GUI front end to MathEngine's parseRPN() method. It extends Panel and is designed to be added as-is to any AWT GUI. While having a calculator handy is (almost) always good, QRPNCalc's main purpose is to test expressions before they are hard-scripted. RPN notation can be tricky to use and this class provides a way to field test such calculations before they are added to a script.
MathTools XML Processor, or MTXPro, is designed to parse the simple XML generated by some of the MathTools core classes, like Question or MMatrix, and create instances of the corresponding classes. MTXPro can parse data from a File, String, or InputSource, and produce a List of the resulting Objects. It is completely self-contained and requires only a SAXParserFactory capable of producing namespace-aware SAXParsers.
MTXPro extends MTXErrorHandler
, so it can also be used as a DefaultHandler in an external SAXParser. Either way, it is designed specifically to
parse and instantiate MathTools Objects from XML markup. It is, of course, one of the standard objects exposed to scripts and, subject to security considerations,
is easily used from there. The one thing MTXPro is not is an XML Swiss army knife. It is designed to consume the XML produced by MathTools (not MathML!)
and convert it to MathTools instances.
For the sake of completeness MTXPro has XSLT capability. XML data from a file or String can be transformed using a stylesheet from a file or String. Parameters can be set for use during transformation and even the Global Pizza can be included!
For creating XML beyond MathXML
, MTXPro has equipment to parse a file or raw String into a DOM tree. The tree is returned and can be manipulated
from there. It can also create a blank DOM Document
, which allows creation of most other DOM components. A DOM tree or Document can then be transformed
via XSLT or filtered via XPath.
MTXErrorHandler
extends org.xml.sax.helpers.DefaultHandler
and implements javax.xml.transform.ErrorListener
. It exists
only to catch parsing and transform errors and Exceptions and report them to CapCom
. It can be used as a no-op parser, to verify an XML document,
or as the superclass for a custom MathTools application XML processor. It is the base class of both MTXProcessor
and GraphHandler
.
It is important to note that despite its name MTXErrorHandler
does not actually handle errors it merely reports them.
The MathFileIO
provides scripts and applications (but not Applets) the tools to read and write files. MTApplet
does not have access
to this class nor will CapCom
supply one; Applets typically do not have access to the local filesystem.
For scripts and applications, MathFileIO
provides easy access to file I/O. The class itself wraps IO objects, Readers, Writers, InputStreams and
OutputStreams, and provides the methods necessary to interact with them. It also keeps track of all such Objects created and, when IO is done, closes them and
makes them garbage-collectible via the closeAll()
method. ScriptPanel
calls this method automatically but other applications must do
so manually. All Exceptions are caught gracefully and reported and the methods that might throw them all have sensible return values if such occurs.
For advanced users, MathFileIO
has the newRandomAccessFile()
method which creates and returns a RandomAccessFile. Unlike the other
methods this one returns a RandomAccessFile
live and ready to use. It is not wrapped and no Exceptions are caught, although the files so
created are tracked and closed automatically if they are not done manually. (The closeAll()
method handles this, too.)
Caution should be used with RandomAccessFiles! As stated previously, there is no protection layered on them!!!
The MathDBC
class gives MathTools scripts and MTApplet
database access through JDBC. It provides the equipment required to
create java.sql.Connection
objects using supplied drivers (DriverManager
) or through DataSource
instances (JNDI). While
creating and configuring JNDI is beyond the scope of MathTools, it can certainly use JNDI if it is available.
The service MathDBC
provides is fairly minimal. It creates and returns Connections; from there it is the script's or application's responsibility
to actually use them. The only other service it does provide is Connection tracking and closing via the closeAll()
method. This is essentially
identical to MathFileIO.closeAll()
, both in function and in philosophy.
Noteworthy is a markup scheme that allows HTML-extractable content to be embedded in plain text lectuer notes. The format is simple and readable. The
NoteworthyParser
class accepts Noteworthy input and produces a MathTools.markup.html.MathGenHTML
instance containing the transformed
document. The combination of the text notes and HTML content allows HTML slide presentations to be integrated into and around the notes used with them.
The MathTools package is designed as an aid to creating printed tests. There is, however, no reason it cannot be deployed and used in test software meant to
be installed at individual workstations. Toward this end the MAuthenticator
interface provides the framework for authenticating persons using
such an application. Three authentication levels are specified: Student, Proctor, and Instructor. (Admin and None are also provided but they are intended for
development and debugging!) Authentication is provided by means of a String authentication code which is fed to the mAuthenticate()
method
along with the level deisred. That method returns true or false, depending on whether or not the code is valid.
Exactly how authentication takes place is not specified. MAuthenticator
provides the framework and CapCom
provides its support to
the rest of the MathTools classes. CapCom
allows a global Authenticator to be set, by classname, and feeds all authentication-specific interaction
to it.
The interface also provides the generateCodes()
method to generate authentication codes at a specific level. Use of this method is not mandatory
but it can make authentication code generation very, very easy! The theory behind the interface is that the authentication code itself contains all necessary
information and that no external information is required. This is theory, though, and it is not enforced!
The SimpleAuthenticator
class provides a full implementation of the MAuthenticator
interface. It serves as both an example of how to
implement the interface and as an authentication tool. The only configuration parameter is a 2+ digit prime number and this is optional: a default is available.
SimpleAuthenticator
is completely self-contained and does not require external resources. As-is it is a moderately secure implementation. By
changing its 'seed' it becomes even stronger. Either way it should be easily usable for a deployed testing application in a monitored or proctored environment.
For off-site or online applications, though, a stronger or different implementation might be required.
The MathToolsAccessory
interface provides a way to add custom user classes without breaking into the JAR or CapCom.installStandardObjects()
. The interface defines one method: processCommand(String, Object...)
. This can be used as a control and access method but the interface
is primarily meant as a marker; the method is there for applications or scripting languages that are picky about exposing non-interface methods.
Accessories are acquired via CapCom.createAccessory()
and are accessible through MathEngine
. As with MAuthenticator
s
accessory creation can be disabled or enabled with the CapCom.allowAccessories
field.
|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |