|
qflib 0.98.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--de.qfs.lib.util.MessageCollector
Very simple mechanism for collecting warning and error messages.
This class is intended for use in a parser or similar application where
many warnings and errors may arise during one run. Each message passed to
the MessageCollector is assigned a level of severity, WARNING for warnings, ERROR for errors and FATAL_ERROR for fatal errors. After processing is finished,
the number of warnings, errors and fatal errors can be queried and the
collected messages are available via getMessages.
Things get even more interesting when nested calls need to be handled,
e.g. when a parser needs to include files. To that end an instance mechanism is implemented that associates a MessageCollector with
the current thread. For JDK 1.2 and above, ThreadLocal is used for this, but for JDK 1.1 be sure to release MessageCollector instances before a thread terminates, or they
will become uncollectable garbage.
| Field Summary | |
static int |
ERROR
Level for errors. |
static int |
FATAL_ERROR
Level for fatal errors. |
static int |
NO_ERROR
Level for neither warnings nor errors. |
static int |
WARNING
Level for warnings. |
| Constructor Summary | |
MessageCollector()
Create a new MessageCollector. |
|
| Method Summary | |
void |
addMessage(int level,
java.lang.String message)
Add a message to the MessageCollector. |
int |
getErrorCount()
Get the number of errors that occured. |
int |
getFatalErrorCount()
Get the number of fatal errors that occured. |
java.lang.String[] |
getMessages()
Get the collected messages. |
int |
getWarningCount()
Get the number of warnings that occured. |
int |
getWorstCase()
Get the highest level of the collected messages. |
static MessageCollector |
instance()
Get the MessageCollector for the current thread, creating a new one if necessary. |
static void |
release()
Destroy the MessageCollector for the current thread. |
void |
reset()
Reset the MessageCollector by clearing the collected messages and resetting the counts. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int NO_ERROR
public static final int WARNING
public static final int ERROR
public static final int FATAL_ERROR
| Constructor Detail |
public MessageCollector()
| Method Detail |
public static MessageCollector instance()
public static void release()
public void addMessage(int level,
java.lang.String message)
level - The level of the message.message - The message.public java.lang.String[] getMessages()
public int getWarningCount()
public int getErrorCount()
public int getFatalErrorCount()
public int getWorstCase()
public void reset()
|
qflib 0.98.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||