cox.jmatt.java.MathTools.test
Interface COFormatter


public interface COFormatter

This interface is designed to allow custom Object formatting for the core MathTools classes that might need it. Specifically it applies to the classes that represent actual mathematical things. All return values are cast as generic Object to allow maximum flexibility. As with the GraphPaper.render() method once a Custom Object Formatter finishes its work MathTools' is done.

The formatGeneric() method is provided to catch anything not covered specifically that might need formatting. Question and Percent instances should not need formatting but the methods are provided in case they do.

In addition to the methods specified below classes implementing COFormatter must have a zero-argument constructor. This is the one used by COFormatterFactory to create instances.

Context Objects

The context Object is treated more formally here than in the graphing.* package. It is created using a String key (optionally) and it is assumed to contain all relevant contextual information needed to format the MathTools object. As with GraphKeys it is optional but provided if needed.


Method Summary
 java.lang.Object format(MathStat pMStat, java.lang.Object pContext)
          Format a MathStat Object.
 java.lang.Object format(MComplex pMCplx, java.lang.Object pContext)
          Format a MComplex per the supplied context.
 java.lang.Object format(MEquation pEqn, java.lang.Object pContext)
          Format a MEquation.
 java.lang.Object format(MFraction pFrac, java.lang.Object pContext)
          Format a MFraction.
 java.lang.Object format(MMatrix pMatrix, java.lang.Object pContext)
          Format a MMatrix properly.
 java.lang.Object format(MRadical pRoot, java.lang.Object pContext)
          Format a MRadical.
 java.lang.Object format(Polynomial pPoly, java.lang.Object pContext)
          Format a Polynomial.
 java.lang.Object format(Question pQues, java.lang.Object pContext)
          Format a Question.
 java.lang.Object formatGeneric(java.lang.Object pObject, java.lang.Object pContext)
          This method is provided to format anything not covered specifically.
 java.lang.Object formatXML(org.w3c.dom.Node pData, java.lang.Object pContext)
          Format XML data contained in a DOM Node.
 java.lang.Object formatXML(java.lang.String pData, java.lang.Object pContext)
          Format XML content represented as a String.
 java.lang.Object getContext(java.lang.String pType)
          Get the formatting context Object if such is needed.
 boolean setParameter(java.lang.String pKey, java.lang.Object pValue)
          This is a very generic method used to configure the COFormatter instance.
 

Method Detail

getContext

java.lang.Object getContext(java.lang.String pType)
Get the formatting context Object if such is needed. A String key is provided to allow for multiple context types.

Parameters:
pType - The type of context to create.
Returns:
The context Object appropriate for the implementation and the task at hand.

format

java.lang.Object format(MFraction pFrac,
                        java.lang.Object pContext)
Format a MFraction.

Parameters:
pFrac - The MFraction to be formatted.
pContext - The context Object containing formatting information.

format

java.lang.Object format(MEquation pEqn,
                        java.lang.Object pContext)
Format a MEquation.

Parameters:
pEqn - The MEquation to be formatted.
pContext - The context Object containing formatting information.

format

java.lang.Object format(MRadical pRoot,
                        java.lang.Object pContext)
Format a MRadical.

Parameters:
pRoot - The MRadical to be formatted.
pContext - The context Object.

format

java.lang.Object format(MMatrix pMatrix,
                        java.lang.Object pContext)
Format a MMatrix properly.

Parameters:
pMatrix - The MMatrix to be formatted.
pContext - The formatting context Object.

format

java.lang.Object format(Polynomial pPoly,
                        java.lang.Object pContext)
Format a Polynomial. This method must take all terms into account.

Parameters:
pPoly - The Polynomial to be formatted.
pContext - The context Object containing formatting information.

format

java.lang.Object format(Question pQues,
                        java.lang.Object pContext)
Format a Question. The data within the question should be formatted internally but this method is provided in case it isn't.

Parameters:
pQues - The Question to format.
pContext - The context Object for formatting.

format

java.lang.Object format(MathStat pMStat,
                        java.lang.Object pContext)
Format a MathStat Object.

Parameters:
pMStat - The MathStat to format.
pContext - The Context Object.

format

java.lang.Object format(MComplex pMCplx,
                        java.lang.Object pContext)
Format a MComplex per the supplied context.


formatGeneric

java.lang.Object formatGeneric(java.lang.Object pObject,
                               java.lang.Object pContext)
This method is provided to format anything not covered specifically.

Parameters:
pObject - The Object to format.
pContext - The formatting Context to use.

formatXML

java.lang.Object formatXML(java.lang.String pData,
                           java.lang.Object pContext)
Format XML content represented as a String. No assumptions are made other than that the raw data is in String form.

Parameters:
pData - The XML data to format.
pContext - The formatting Context Object.

formatXML

java.lang.Object formatXML(org.w3c.dom.Node pData,
                           java.lang.Object pContext)
Format XML data contained in a DOM Node.

Parameters:
pData - The DOM Node XML data.
pContext - The format Context.

setParameter

boolean setParameter(java.lang.String pKey,
                     java.lang.Object pValue)
This is a very generic method used to configure the COFormatter instance. How it is used or if it is used must be specified in the implementation documentation. The return value should only be false if the parameter requested absolutely cannot be set as requested.

Parameters:
pKey - The name of the parameter to set.
pValue - The value of the parameter set.
Returns:
True or false, depending on the parameter, the value and the implementation.