|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcox.jmatt.java.MathTools.util.MathConsole
public class MathConsole
This class exists to provide scripting languages access to the MathTools logging framework and Global Pizza. If subclassing, DO NOT implement the MathPrinter interface and set the subclass as either the Global Printer OR the subclass' MathPrinter. The universe will implode if this happens!
Field Summary | |
---|---|
static java.lang.String |
AUTH_SIMPLE
String constant for a SimpleAuthenticator . |
static byte |
INSTRUCTOR
Static constant for Instructor authentication codes. |
static byte |
PROCTOR
Static constant for Proctor codes. |
static byte |
STUDENT
Static constant for generating Student codes. |
Constructor Summary | |
---|---|
MathConsole()
The basic MathConsole constructor. |
|
MathConsole(MathPrinter pPrinter)
Build a MathConsole around a MathPrinter instance. |
|
MathConsole(MathPrinter pPrinter,
java.util.Properties pPizza)
Build a MathConsole completely separate from CapCom. |
Method Summary | |
---|---|
void |
abort(java.lang.String pMesg)
Sometimes a script needs to generate an error and terminate. |
boolean |
authenticateInstructor(java.lang.String pCode)
Check an authentication code at Instructor level. |
boolean |
authenticateProctor(java.lang.String pCode)
Check an authentication code at Proctor level. |
boolean |
authenticateStudent(java.lang.String pCode)
Check an authentication code at Student level. |
void |
debug(java.lang.String pMesg)
|
void |
debug(java.lang.String pMesg,
java.lang.Throwable pThr)
|
void |
error(java.lang.String pMesg)
|
void |
error(java.lang.String pMesg,
java.lang.Throwable pThr)
|
java.lang.String[] |
generateCodes(byte pLevel,
int pNumberOf,
java.lang.Object... pParams)
Generate a set of authentication codes, if access is permitted. |
java.lang.Object |
getObject(java.lang.String pKey)
Get an Object from the CapCom shelf. |
java.lang.String |
getProperty(java.lang.String pKey)
Convenience method for getProperty(pKey, null). |
java.lang.String |
getProperty(java.lang.String pKey,
java.lang.String pDefault)
Fetch a property from a Properties object. |
void |
info(java.lang.String pMesg)
|
void |
info(java.lang.String pMesg,
java.lang.Throwable pThr)
|
void |
mathLog(byte pLevel,
java.lang.String pMessage,
java.lang.Throwable pThr)
This method intercepts all logging calls made on this method directly OR on its convenience methods. |
void |
mathPrintln(java.lang.String pMessage)
Print a message outside the logging framework. |
void |
println(java.lang.String pMessage)
Laziness method aliasing mathPrintln(). |
java.lang.Object |
processMathObject(java.lang.Object pData)
Process an Object on a MathPrinter. |
java.lang.Object |
returns(java.lang.Object pRetObject)
This method is used to explicitly store a return Object from a script. |
void |
setAuthenticator(java.lang.String pName,
java.lang.Object pCtx)
Install an Authenticator. |
void |
storeObject(java.lang.String pKey,
java.lang.Object pData)
Store something on the CapCom shelf. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte STUDENT
public static final byte PROCTOR
public static final byte INSTRUCTOR
public static final java.lang.String AUTH_SIMPLE
SimpleAuthenticator
.
Constructor Detail |
---|
public MathConsole()
public MathConsole(MathPrinter pPrinter)
public MathConsole(MathPrinter pPrinter, java.util.Properties pPizza)
pPrinter
- The MathPrinter to use for logging/printing calls. If null, CapCom is used.pPizza
- The Properties object to use for getProperty() calls. If null, the Global Pizza is used.Method Detail |
---|
public void mathLog(byte pLevel, java.lang.String pMessage, java.lang.Throwable pThr)
This method intercepts all logging calls made on this method directly OR on its convenience methods. If this console is built around a MathPrinter, that printer receives all calls. If not, this method reflects to the CapCom mathLog() method.
As with CapCom, MathConsole provides convenience methods for Debug, Info and Error: one method accepting a String and another that accepts a String and a Throwable.
public void error(java.lang.String pMesg)
public void error(java.lang.String pMesg, java.lang.Throwable pThr)
public void debug(java.lang.String pMesg)
public void debug(java.lang.String pMesg, java.lang.Throwable pThr)
public void info(java.lang.String pMesg)
public void info(java.lang.String pMesg, java.lang.Throwable pThr)
public void mathPrintln(java.lang.String pMessage)
pMessage
- The message to be printed.public void println(java.lang.String pMessage)
public java.lang.Object processMathObject(java.lang.Object pData)
public void abort(java.lang.String pMesg) throws java.lang.Exception
Sometimes a script needs to generate an error and terminate. This method does that. If the message is null or blank a default is supplied. When
called, this method throws a generic Exception
which will be caught by ScriptPanel
. The message should always be specified and
it should always be descriptive of the error condition.
pMesg
- The message to include in the Exception.
java.lang.Exception
public java.lang.String getProperty(java.lang.String pKey, java.lang.String pDefault)
pKey
- The key of the property to be fetched. If not valid, the default is returned.pDefault
- The String (or null) to return if the specified property can't be found.public java.lang.String getProperty(java.lang.String pKey)
public java.lang.Object getObject(java.lang.String pKey)
pKey
- The String key under which the Object was stored.
public void storeObject(java.lang.String pKey, java.lang.Object pData)
pKey
- The String key under which the Object is to be shelved.pData
- The Object to be stored.public final java.lang.Object returns(java.lang.Object pRetObject)
This method is used to explicitly store a return Object from a script. When called it calls CapCom.setScriptReturnObject(java.lang.Object)
and returns whatever value was sent in. This is done to facilitate the following:
Console.returns(someObject)
ScriptEngine.eval()
method actually returns a value.
pRetObject
- The return value from the script
public final boolean authenticateStudent(java.lang.String pCode)
public final boolean authenticateProctor(java.lang.String pCode)
code
at Proctor level. This and all other Authenticator methods reflect to
CapCom
.
public final boolean authenticateInstructor(java.lang.String pCode)
public final void setAuthenticator(java.lang.String pName, java.lang.Object pCtx)
CapCom.allowConsoleAuthenticatorAccess
to false blocks it.
pName
- The full name of the MAuthenticator
to install.pCtx
- The context Object, if required.public final java.lang.String[] generateCodes(byte pLevel, int pNumberOf, java.lang.Object... pParams)
generateCodes()
in the MAuthenticator
interface. As with setting the authenticator, this method can be disabled from CapCom. If access is not allowed the return
value is null. The authentication levels are reflected in static constants here for convenience.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |