cox.jmatt.java.MathTools.test
Class MTestParser

java.lang.Object
  extended by cox.jmatt.java.MathTools.test.MTestParser

public class MTestParser
extends java.lang.Object

This simple class is designed to parse text into a MTest. The method used to add Questions is Question.parseQuestion() and all default settings apply. A very simple macro language allows setting of options and MTFIs. The input can come from a file, a resource stream or a String of newline-separated text.

All macro commands start with the '@' character and consist of a single letter and possibly text afterward. The macro commands are:

Lowercase letters also work.

The intent of this class is to allow quick creation of a simple MTest. Since MTest is very much line-oriented it lends itself particularly well to LaTeX. LaTeX handles its own page layout so line-orientation suffices for the raw input. Also, since a MTest can be set before data is parsed this class can also be used to configure large parts of the test that don't really change.


Constructor Summary
MTestParser()
          The only constructor needed.
 
Method Summary
 MTest parse(java.lang.String pData)
          Parse a String into a MTest.
 MTest parseFile(java.lang.String pFile, boolean pGRAS)
          Parse a file into a MTest.
 MTestParser reset()
          Reset the parser to its default values: true for autoclick and no pre-set MTest.
 MTestParser setAutoClick(boolean yesNo)
          This method sets the global autoclick value.
 MTestParser setMTest(MTest pTest)
          Use this method to set the MTest instance used to receive the parsed data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MTestParser

public MTestParser()
The only constructor needed. Ever.

Method Detail

setAutoClick

public MTestParser setAutoClick(boolean yesNo)
This method sets the global autoclick value. If true, each time a Question is added its click() method is called.


setMTest

public MTestParser setMTest(MTest pTest)
Use this method to set the MTest instance used to receive the parsed data. If set to null a new MTest is used.


reset

public MTestParser reset()
Reset the parser to its default values: true for autoclick and no pre-set MTest.


parse

public MTest parse(java.lang.String pData)
Parse a String into a MTest. The parser breaks on newlines and this is not configurable.

Parameters:
pData - The String to be parsed.

parseFile

public MTest parseFile(java.lang.String pFile,
                       boolean pGRAS)
Parse a file into a MTest. This may be on the filesystem or from a resource stream. If the latter, it will automatically use the Math ClassLoader.

Parameters:
pFile - The name of the file to parse.
pGRAS - true to getResourceAsStream(), false for a file.