|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcox.jmatt.java.MathTools.test.MTest
public class MTest
MTest
is a simple container for MTestElement
s. It makes provision for holding them in the order in which they are entered,
formatting them and presenting the results. The Problem and Answer parts can be printed individually or sequentially, the internal formats can be used or one
can be specified for Problem and Answer separately.
Formatting via this class does not change any of the data formatted with one exception. When the element content is actually formatted all newline
characters are replaced with the value set in the setNewline()
method. This occurs after the content is pulled from the test elements and before
it is printed so the original data doesn't change.
Constructor Summary | |
---|---|
MTest()
This is the only constructor needed. |
Method Summary | |
---|---|
void |
add(MTestElement mElement)
Add a MTestElement to the internal list. |
void |
addBlock(java.lang.String pContent)
Add a TEXT_BLOCK MTFI element. |
void |
addGraphMark(java.lang.String pContent)
Add a GRAPH_MARK MTFI element. |
void |
addLine(java.lang.String pContent)
Add a TEXT_LINE MTFI element. |
void |
addNote(java.lang.String pContent)
Add a TEXT_NOTE MTFI element. |
void |
addPageBreak()
Add a PAGE_BREAK MTFI element. |
java.lang.String |
format()
Format each element, in order, per the zero-argument format() method. |
java.lang.String |
format(java.lang.String pTemplate)
This method formats each element according to the template String passed in. |
java.lang.String |
formatAnswers()
This method calls formatAnswer() on each element on the test. |
java.lang.String |
formatProblems()
This method calls formatProblem() on each element on the test. |
java.lang.String |
formatTest()
Convenience method for formatTest(null) . |
java.lang.String |
formatTest(java.lang.String pKeySep)
This method calls formatProblems() and formatAnswers() and concatenates the results. |
MTestParser |
getNewParser()
Instance method to crate a new parser. |
static MTestParser |
getParser()
Create and return a new MTestParser . |
static java.lang.String |
replaceNewlines(java.lang.String pRaw)
This method replaces newline characters ('\n') with whatever value is set, other than '\n' (... |
void |
reset()
Reset everything on the test. |
static void |
set_XML_escape(boolean yesNo)
Set the (static) XML escape flag. |
void |
setEscapeXML(boolean yesNo)
Instance shadow to set XML escape. |
void |
setFormatMTFI(java.lang.String pFormat)
Set the 'entire' format for MTFI. |
void |
setLineSeparator(java.lang.String pNewSep)
Set the separator appended to each element's content when it is formatted. |
void |
setNewline(char pChar)
Set the character or character sequence used for newlines. |
void |
setShowID_MTFI(boolean yesNo)
Toggle MTFI ID display in formatting token 0. |
java.lang.String |
toString()
Overridden. |
java.lang.String |
toXML()
Convert all elements to XML. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MTest()
This is the only constructor needed.
Method Detail |
---|
public final void setNewline(char pChar)
Set the character or character sequence used for newlines. This is the only formatting 'change' MTest makes to any content. There are three choices:
Uppercase or lowercase characters work equally well but ONLY the three characters, as char, are valid values. Any others are ignored.
public static void set_XML_escape(boolean yesNo)
MTFI
's escape. It is assumed that any Question
s will handle themselves.
public static java.lang.String replaceNewlines(java.lang.String pRaw)
public void setEscapeXML(boolean yesNo)
public void setLineSeparator(java.lang.String pNewSep)
public void setFormatMTFI(java.lang.String pFormat)
public void setShowID_MTFI(boolean yesNo)
public void reset()
public static MTestParser getParser()
MTestParser
.
public MTestParser getNewParser()
public void add(MTestElement mElement)
MTestElement
to the internal list. If mElement is null it is silently ignored.
mElement
- The MTestElement
to add to the test. Ignored if null.public void addLine(java.lang.String pContent)
TEXT_LINE MTFI
element. Silently ignored if pContent is null or blank.
public void addBlock(java.lang.String pContent)
TEXT_BLOCK MTFI
element. Silently ignored if pContent is null or blank.
public void addNote(java.lang.String pContent)
TEXT_NOTE MTFI
element. Silently ignored if pContent is null or blank.
public void addGraphMark(java.lang.String pContent)
GRAPH_MARK MTFI
element. If pContent is null or blank a default ID is assigned.
public void addPageBreak()
PAGE_BREAK MTFI
element.
public java.lang.String format()
format()
method. The internal line separator is appended after each element and all
content is newline-replaced.
public java.lang.String format(java.lang.String pTemplate)
This method formats each element according to the template String passed in. No validity-checking is done on the template. The line separator is appended to each element and newlines are replaced.
Replacement tokens are per Question
.
pTemplate
- The template String by which each element is to be formatted.public java.lang.String formatProblems()
This method calls formatProblem()
on each element on the test. The line separator is appended and newlines replaced.
public java.lang.String formatAnswers()
This method calls formatAnswer()
on each element on the test. The line separator is appended and newlines replaced.
public java.lang.String formatTest(java.lang.String pKeySep)
formatProblems()
and formatAnswers()
and concatenates the results. If pKeySep is not null it is newline-replaced
and placed between the Problems and Answers.
pKeySep
- A String to be placed between the formatProblems()
and formatAnswers()
results. Ignored if null.public java.lang.String formatTest()
formatTest(null)
.
public java.lang.String toXML()
public java.lang.String toString()
formatTest()
.
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |