Package eu.bandm.tools.message
Class MessageCounter
java.lang.Object
eu.bandm.tools.message.MessageCounter
- All Implemented Interfaces:
MessageReceiver<Message>
Counts all received messages, per kind, in total, and per critical/non-critical.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Is used to count the messages for one particular kind. -
Field Summary
Modifier and TypeFieldDescriptionprotected int
Counts the critical errors, that are erros and failures.protected Map<Message.Kind,
MessageCounter.Counter> Evidentprotected int
Memorizes the number of critical errors at the beginning of one processing phase, to compare it with the number at the end of that phase.static final MessageReceiver<Message>
Discards all messages but throws an AssertionError if an error is encountered. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
_toString
(boolean filter) Auxiliary method.int
getCounts
(Message.Kind kind) Returns the count of messages of the givenMessage.Kind
it has received since its creation or the last call toresetCounters()
int
Returns the count of all critical messages it has received since its creation or the last call toresetCounters()
.int
Returns the number of new critical errors occured after the last call tomarkCriticalErrors()
int
getSum()
Returns the count of all messages it has received since its creation or the last call toresetCounters()
boolean
Returns whether critical messages have received since its creation or the last call toresetCounters()
.int
Stores the number of critical errors for later retrieval bygetMarkedErrors()
.Deliver a simple, english based text representation, only mentioning non-zero counters.void
Advance one or two counters, depending on the message's kind.void
Restart the counter for one particularMessage.Kind
with 0(zero).void
Restart all counting with 0(zero), as if the counter object had just been created.void
Print an (English) text to std err and termnate application with result code==1, iff errors or failures have been counted.toString()
Deliver a simple, english based text representation of all counters.
-
Field Details
-
counters
Evident -
countCritical
protected int countCriticalCounts the critical errors, that are erros and failures. -
criticalMark
protected int criticalMarkMemorizes the number of critical errors at the beginning of one processing phase, to compare it with the number at the end of that phase. -
noErrors
Discards all messages but throws an AssertionError if an error is encountered. Used for initialization code on constant input data which is asserted to run without errors and for which no message output is needed/requested. Throws AssertionError if an Error or a Failure is received.
-
-
Constructor Details
-
MessageCounter
public MessageCounter()Evident
-
-
Method Details
-
getCounts
Returns the count of messages of the givenMessage.Kind
it has received since its creation or the last call toresetCounters()
-
getSum
public int getSum()Returns the count of all messages it has received since its creation or the last call toresetCounters()
-
markCriticalErrors
public int markCriticalErrors()Stores the number of critical errors for later retrieval bygetMarkedErrors()
. This is called a the beginnig of a processing phase. -
getMarkedErrors
public int getMarkedErrors()Returns the number of new critical errors occured after the last call tomarkCriticalErrors()
-
getCriticalCount
public int getCriticalCount()Returns the count of all critical messages it has received since its creation or the last call toresetCounters()
.
Critical messages are those the kind of which is critical, Please cf.Message.isCritical()
. -
hasCriticals
public boolean hasCriticals()Returns whether critical messages have received since its creation or the last call toresetCounters()
.
Critical messages are those the kind of which is critical, Please cf.Message.isCritical()
. -
resetCounter
Restart the counter for one particularMessage.Kind
with 0(zero). Also re-adjust critical count. -
resetCounters
public void resetCounters()Restart all counting with 0(zero), as if the counter object had just been created. -
receive
Advance one or two counters, depending on the message's kind.- Specified by:
receive
in interfaceMessageReceiver<Message>
-
_toString
Auxiliary method.- Parameters:
filter
- whether to suppress the counters with value =0
-
toString
Deliver a simple, english based text representation of all counters. -
nonZeroToString
Deliver a simple, english based text representation, only mentioning non-zero counters. -
terminateApplicationOnErrors
public void terminateApplicationOnErrors()Print an (English) text to std err and termnate application with result code==1, iff errors or failures have been counted.
-