public class Messages
extends java.lang.Object
The number of reported errors can be limited, thus providing a "governor" on processing (to a point).
Keeps track of the number of error and informational messages so that processing can be terminated if desired when no further output will be accumulated, particularly with error messages... The rationale of which is that if the Metamath .mm has basic Metamath language errors, such as invalid keywords, etc., there is no point in attempting Proof Verification or Syntax Verification. Also, processes that follow the System Load require a "clean" system, and the code assumes the integrity of LogicalSystem's data.
Various "print" functions in Messages accept a java.io.PrintWriter object so that output can be directed somewhere besides System.out. This also allows for the possibility of writing in other, non-default character sets such as UTF-8.
Modifier and Type | Class and Description |
---|---|
class |
Messages.InstrumentationTimer |
Modifier and Type | Field and Description |
---|---|
protected java.lang.String[] |
errorMessageArray
String array of error messages in Messages object.
|
protected int |
errorMessageCnt
Count of error messages stored in Messages object.
|
protected java.lang.String[] |
infoMessageArray
String array of info messages in Messages object.
|
protected int |
infoMessageCnt
Count of info messages stored in Messages object.
|
protected java.util.Hashtable<java.lang.String,Messages.InstrumentationTimer> |
instrumentationTable |
Constructor and Description |
---|
Messages()
Default constructor using LangConstants.MAX_ERROR_MESSAGES_DEFAULT and
LangConstants.MAX_INFO_MESSAGES_DEFAULT.
|
Messages(int maxErrorMessages,
int maxInfoMessages)
Constructor using max error/info message params.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accumErrorMessage(java.lang.String errorMessage,
java.lang.Object... args)
Accum error message in Messages repository.
|
boolean |
accumException(MMJException e)
Accum an
MMJException in Messages repository. |
boolean |
accumInfoMessage(java.lang.String infoMessage,
java.lang.Object... args)
Accum info message in Messages repository.
|
boolean |
accumMessage(ErrorCode code,
java.lang.Object... args)
Accum info/error message in Messages repository.
|
void |
clearMessages()
Empty message arrays and reset counters to zero.
|
java.lang.String[] |
getErrorMessageArray()
Return error message array.
|
int |
getErrorMessageCnt()
Return count of error messages stored in Messages object.
|
java.lang.String[] |
getInfoMessageArray()
Return info message array.
|
int |
getInfoMessageCnt()
Return count of info messages stored in Messages object.
|
boolean |
maxErrorMessagesReached()
Check max error messages (table full).
|
void |
printAndClearMessages()
Print all messages to System.out and clear message arrays.
|
void |
printAndClearMessages(java.io.PrintStream printStream)
Print all messages to printStream and clear message arrays.
|
void |
printErrorMessages()
Print error messages to System.out.
|
void |
printErrorMessages(java.io.PrintStream printStream)
Print error messages to printStream.
|
void |
printInfoMessages()
Print info messages to System.out.
|
void |
printInfoMessages(java.io.PrintStream printStream)
Print info messages to printStream.
|
void |
printMessages()
Print all messages to System.out.
|
void |
printMessages(java.io.PrintStream printStream)
Print all messages to printStream.
|
void |
reallocateErrorMessages(int maxErrorMessages)
Reallocate error message array with new size.
|
void |
reallocateInfoMessages(int maxInfoMessages)
Reallocate info message array with new size.
|
void |
startInstrumentationTimer(java.lang.String timerID) |
void |
stopInstrumentationTimer(java.lang.String inTimerID) |
void |
writeAndClearMessages(java.io.PrintWriter printWriter)
Write all messages to printWriter and clear message arrays.
|
void |
writeErrorMessages(java.io.PrintWriter printWriter)
Write error messages to printWriter.
|
void |
writeInfoMessages(java.io.PrintWriter printWriter)
Write info messages to printWriter.
|
void |
writeMessages(java.io.PrintWriter printWriter)
Write all messages to printWriter.
|
protected int errorMessageCnt
protected int infoMessageCnt
protected java.lang.String[] errorMessageArray
protected java.lang.String[] infoMessageArray
protected java.util.Hashtable<java.lang.String,Messages.InstrumentationTimer> instrumentationTable
public Messages()
public Messages(int maxErrorMessages, int maxInfoMessages)
maxErrorMessages
- max error messages to be stored.maxInfoMessages
- max info messages to be stored.java.lang.IllegalArgumentException
- if "max" params < 1.public void reallocateErrorMessages(int maxErrorMessages)
maxErrorMessages
- max error messages to be stored.java.lang.IllegalArgumentException
- if "max" param < 1.public void reallocateInfoMessages(int maxInfoMessages)
maxInfoMessages
- max info messages to be stored.java.lang.IllegalArgumentException
- if "max" param < 1.public boolean accumException(MMJException e)
MMJException
in Messages repository.
Stores the new message if there is room in the array.
e
- exceptionpublic boolean accumMessage(ErrorCode code, java.lang.Object... args)
Stores the new message if there is room in the array.
code
- error message.args
- formatting arguments.public boolean accumErrorMessage(java.lang.String errorMessage, java.lang.Object... args)
Stores the new message if there is room in the array.
errorMessage
- error message.args
- formatting arguments.public boolean accumInfoMessage(java.lang.String infoMessage, java.lang.Object... args)
Stores the new message if there is room in the array.
infoMessage
- info message.args
- formatting arguments.public int getErrorMessageCnt()
public boolean maxErrorMessagesReached()
public int getInfoMessageCnt()
public java.lang.String[] getErrorMessageArray()
public java.lang.String[] getInfoMessageArray()
public void printAndClearMessages()
public void printMessages()
public void printAndClearMessages(java.io.PrintStream printStream)
printStream
- the PrintStreampublic void printMessages(java.io.PrintStream printStream)
printStream
- the PrintStreampublic void writeAndClearMessages(java.io.PrintWriter printWriter)
printWriter
- the PrintWriterpublic void writeMessages(java.io.PrintWriter printWriter)
printWriter
- the PrintWriterpublic void printErrorMessages()
public void printInfoMessages()
public void printErrorMessages(java.io.PrintStream printStream)
printStream
- the PrintStreampublic void writeErrorMessages(java.io.PrintWriter printWriter)
printWriter
- the PrintWriterpublic void printInfoMessages(java.io.PrintStream printStream)
printStream
- the PrintStreampublic void writeInfoMessages(java.io.PrintWriter printWriter)
printWriter
- the PrintWriterpublic void clearMessages()
public void startInstrumentationTimer(java.lang.String timerID)
public void stopInstrumentationTimer(java.lang.String inTimerID)