cox.jmatt.java.MathTools.test
Class MTFI

java.lang.Object
  extended by cox.jmatt.java.MathTools.test.MTFI
All Implemented Interfaces:
MTestElement

public class MTFI
extends java.lang.Object
implements MTestElement

This class provides a Math Test Formatting Item or MTFI. At its most basic level a MTFI is a bit of text placed on a test. The 'Format Item' comes from the purpose for which the 'bit of text' is used. MTFI provides five distinct types of items all explained in the FIType enum.

Briefly, the item types are:

All of the items except PAGE_BREAK have content associated with them. For GRAPH_MARK it is assumed to be a short identifier for what graph should appear. The 'TEXT_' elements contain text content intended to appear on the actual test, or answer key in the case of TEXT_NOTE.

This documentation is provided primarily for element explanation and embedding. There should be no need to instantiate this class directly: MTest handles it automatically.


Nested Class Summary
static class MTFI.FIType
          The Format Item Type enum provides the valid types a MTFI can be.
 
Field Summary
static java.lang.String DEFAULT_GLOBAL_FORMAT
          Default 'entire' format for all MTFI types: '<0:gt;<1> <2>'.
 
Constructor Summary
MTFI(MTFI.FIType pType, java.lang.String pContent)
          This is the only public constructor; a type is ABSOLUTELY required, even though content may be optional.
 
Method Summary
 MTFI copyOf()
          Create a copy of this element.
 java.lang.String format()
          Format using the internal template.
 java.lang.String format(java.lang.String pTemplate)
          This class' raison-d'etre.
 java.lang.String formatAnswer()
          Call format() when printing answers.
 java.lang.String formatProblem()
          Call format() when appropriate.
static MTFI newInstance(java.lang.String pType, java.lang.String pContent)
          This method is used by MTXProcessor to re-create format items from MathTools XML markup.
static void setEscapeXML(boolean yesNo)
          This class maintains a global XML escape flag.
static void setFormat(java.lang.String pFormat)
          Set the 'entire MTFI' format, analogous to the 'entire Question' format.
static void setShowID(boolean yesNo)
          Set to 'true' to show MTFI type in replacement token 0 when formatting.
 java.lang.String toXML()
          Print an XML representation of this format itme.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_GLOBAL_FORMAT

public static final java.lang.String DEFAULT_GLOBAL_FORMAT
Default 'entire' format for all MTFI types: '<0:gt;<1> <2>'.

See Also:
Constant Field Values
Constructor Detail

MTFI

public MTFI(MTFI.FIType pType,
            java.lang.String pContent)
This is the only public constructor; a type is ABSOLUTELY required, even though content may be optional.

Method Detail

setEscapeXML

public static void setEscapeXML(boolean yesNo)
This class maintains a global XML escape flag. Setting once sets it for all instances until it is reset. This method sets it.


setFormat

public static void setFormat(java.lang.String pFormat)
Set the 'entire MTFI' format, analogous to the 'entire Question' format. Setting to null or blank resets the default.


setShowID

public static void setShowID(boolean yesNo)
Set to 'true' to show MTFI type in replacement token 0 when formatting. Defaults to false.


newInstance

public static MTFI newInstance(java.lang.String pType,
                               java.lang.String pContent)
This method is used by MTXProcessor to re-create format items from MathTools XML markup. If pType is not valid a TEXT_LINE with an error message is created. Any errors are reported at Error level.

Parameters:
pType - The type of MTFI to create.
pContent - The tag content, if needed.

format

public java.lang.String format(java.lang.String pTemplate)

This class' raison-d'etre. All other format methods echo to this one. Even thogh MTFI doesn't have Problem and Answer parts per se, the content is handled similarly and consistently with Question's replacement tokens: <1> prints with the Problems and <2> prints with the Answers. All other tokens are blank and this is handled automatically.

Default templates are supplied, they should be appropriate for most cases.

Specified by:
format in interface MTestElement
Parameters:
pTemplate - The template String for formatting.

format

public java.lang.String format()
Format using the internal template.

Specified by:
format in interface MTestElement

toXML

public java.lang.String toXML()
Print an XML representation of this format itme.

Specified by:
toXML in interface MTestElement

formatProblem

public java.lang.String formatProblem()
Call format() when appropriate.

Specified by:
formatProblem in interface MTestElement

formatAnswer

public java.lang.String formatAnswer()
Call format() when printing answers.

Specified by:
formatAnswer in interface MTestElement

copyOf

public MTFI copyOf()
Create a copy of this element.

Specified by:
copyOf in interface MTestElement