|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface MessageHandler
A simple API for a message handler.
There are seven types of message, plus a localize method:
| variable | state | description |
|---|---|---|
| localize | normal | returns localized version of message. |
| status | normal | writes localized message to status (UI if available, message if not). |
| log | normal | writes timestamped, localized message to log file. |
| message | normal | writes localized message to designated output. |
| notice | normal | writes localized notice to designated output. |
| warning | error | writes localized warning message to designated output and performs a system exit if the warning count exceeds maxWarnings. |
| error | error | writes localized error message to designated output and performs a system exit if the error count exceeds maxErrors. |
| fatal | error | writes localized error message to stderr and performs a system exit. |
The first method parameter id may be a MessageId reference from the localized ListResourceBundle Messages, or if not recognized as such, will be treated simply as a message String. Following the initial id, each of the four message types is available with one to four additional passed parameters, plus several include exception tunnelling (for compliance with SAX's ErrorHandler). While there is considerable flexibility in available methods, the minimum pattern followed for all is similar to message():
public String message( String id )
public String message( String id, String arg1 )
public String message( String id, String arg1, String arg2 )
public String message( String id, String arg1, String arg2, String arg3 )
etc.
localize(String) is also available with as many as six parameters.
MessageHandlerImpl
to convert MessageHandler state values to Log4J Levels. The API itself
has no dependency on Log4J.
| Field Summary | |
|---|---|
static int |
DEBUG
Not used as a state: Log4J Level = DEBUG. |
static int |
ERROR
State: process error (possibly recoverable). |
static int |
FATAL
State: exit immediately on receiving. |
static int |
INFO
State: informational message. |
static int |
LOCALIZE
State: return localized message. |
static int |
LOG
State: log message. |
static String |
LOG_FEATURE_PFX
Logger Feature prefix. |
static String |
LOG_LEVEL
Feature identifier: message/log (noise) level. |
static String |
MESSAGE_VERBOSE
Feature identifier: log append. |
static String |
MSG_PROPERTY_PFX
MessageHandler Feature prefix. |
static int |
NOTICE
State: highlighted notice. |
static int |
OFF
Not used as a state: Log4J Level = OFF (i.e., logging off). |
static int |
OK
State: no activity. |
static int |
WARN
State: warning message. |
| Method Summary | |
|---|---|
void |
active()
Indicates any kind of application activity, and should be by implementing classes upon any system message sent to the MessageHandler (except requests for localization). |
String |
error(Exception exception)
Tunnel an existing Exception. |
String |
error(String id)
Handle an exception provided an error message and no arguments. |
String |
error(String id,
Exception exception)
Handle an exception provided an error message and no arguments, and the tunneled Exception. |
String |
error(String id,
String arg)
Handle an exception provided an error message and one argument. |
String |
error(String id,
String arg,
Exception exception)
Handle an exception provided an error message with one argument and the tunneled Exception. |
String |
error(String id,
String arg1,
String arg2)
Handle an exception provided an error message and two arguments. |
String |
error(String id,
String arg1,
String arg2,
Exception exception)
Handle an exception provided an error message with two arguments and the tunneled Exception. |
String |
error(String id,
String arg1,
String arg2,
String arg3)
Handle an exception provided an error message and three arguments. |
String |
fatalError(Error error)
A method which handles a fatal error provided the actual java.lang.Error. |
String |
fatalError(Exception exception)
A method which handles a fatal exception given the tunneled Exception. |
String |
fatalError(String id)
A method which handles a fatal exception given an error message String. |
String |
fatalError(String id,
Exception exception)
A method which handles a fatal exception given an error message String and the tunneled Exception. |
String |
fatalError(String id,
String arg1)
A method which handles a fatal exception given an error id, one argument. |
String |
fatalError(String id,
String arg1,
Exception exception)
A method which handles a fatal exception given an error id, one argument, and the tunneled Exception. |
String |
fatalError(String id,
String arg1,
String arg2)
A method which handles a fatal exception given an error id and two arguments. |
String |
fatalError(String id,
String arg1,
String arg2,
Exception exception)
A method which handles a fatal exception given an error id, two arguments, and the tunneled Exception. |
Clock |
getClock()
Returns the Clock object used for generating timestamps. |
int |
getStatus()
Return the current MessageHandler status. |
String |
getStatusText(int status)
Returns a localized String indicating the provided message status. |
Writer |
getWriter()
Returns the Writer used. |
String |
localize(String id)
Return a localized message given a message id and no arguments. |
String |
localize(String id,
String arg1)
Return a localized message given a message id and one argument. |
String |
localize(String id,
String arg1,
String arg2)
Return a localized message given a message id and two arguments. |
String |
localize(String id,
String arg1,
String arg2,
String arg3)
Return a localized message given a message id and three arguments. |
String |
localize(String id,
String arg1,
String arg2,
String arg3,
String arg4)
Return a localized message given a message id and four arguments. |
String |
localize(String id,
String arg1,
String arg2,
String arg3,
String arg4,
String arg5)
Return a localized message given a message id and five arguments. |
String |
localize(String id,
String arg1,
String arg2,
String arg3,
String arg4,
String arg5,
String arg6)
Return a localized message given a message id and six arguments. |
String |
log(String message)
Write the message to the log file, given the message and no arguments. |
String |
log(String timeStamp,
String id)
Write the message to the log file, given an optional time stamp, a message id and no arguments. |
String |
log(String timeStamp,
String id,
String arg1)
Write the message to the log file, given an optional time stamp, a message id and one argument. |
String |
log(String timeStamp,
String id,
String arg1,
String arg2)
Write the message to the log file, given an optional time stamp, a message id and two arguments. |
String |
log(String timeStamp,
String id,
String arg1,
String arg2,
String arg3)
Write the message to the log file, given an optional time stamp, a message id and three arguments. |
String |
log(String timeStamp,
String id,
String arg1,
String arg2,
String arg3,
String arg4)
Write the message to the log file, given an optional time stamp, a message id and four arguments. |
String |
message(String id)
Display a non-fatal informational message given a message id and no arguments. |
String |
message(String id,
String arg1)
Display a non-fatal informational message given a message id and one argument. |
String |
message(String id,
String arg1,
String arg2)
Display a non-fatal informational message given a message id and two arguments. |
String |
message(String id,
String arg1,
String arg2,
String arg3)
Display a non-fatal informational message given a message id and three arguments. |
String |
message(String id,
String arg1,
String arg2,
String arg3,
String arg4)
Display a non-fatal informational message given a message id and four arguments. |
String |
notice(String id)
Display a highlighted notice given a notice id and no arguments. |
String |
notice(String id,
String arg1)
Display a highlighted notice given a notice id and one argument. |
String |
notice(String id,
String arg1,
String arg2)
Display a highlighted notice given a notice id and two arguments. |
String |
notice(String id,
String arg1,
String arg2,
String arg3)
Display a highlighted notice given a notice id and three arguments. |
String |
notice(String id,
String arg1,
String arg2,
String arg3,
String arg4)
Display a highlighted notice given a notice id and four arguments. |
void |
printStackTrace(Throwable throwable)
Prints the stack trace from the provided Throwable to the error output. |
void |
registerListener(MessageWriter msgwriter)
Registers the provided object wi as the receiver for MessageHandler messaging events. |
void |
reset()
Clears all warning and error counters and containers. |
void |
status(String id)
Display a status message to the UI if available (as a message if not) given a message id and no arguments. |
void |
status(String id,
String arg1)
Display a status message to the UI if available (as a message if not) given a message id and one argument. |
void |
status(String id,
String arg1,
String arg2)
Display a status message to the UI if available (as a message if not) given a message id and two arguments. |
void |
status(String id,
String arg1,
String arg2,
String arg3)
Display a status message to the UI if available (as a message if not) given a message id and three arguments. |
void |
status(String id,
String arg1,
String arg2,
String arg3,
String arg4)
Display a status message to the UI if available (as a message if not) given a message id and four arguments. |
String |
warning(Exception exception)
Tunnel an existing Exception. |
String |
warning(String id)
Display a non-fatal warning given an error message and no arguments. |
String |
warning(String id,
String arg1)
Display a non-fatal warning given an error id and one argument. |
String |
warning(String id,
String arg1,
String arg2)
Display a non-fatal warning given an error id and two arguments. |
String |
warning(String id,
String arg1,
String arg2,
String arg3)
Display a non-fatal warning given an error id and three arguments. |
String |
writeMessage(int status,
String message)
Write the contents of the message to a message display with any indication of message type provided by the status parameter, whose values are one of the state values from MessageHandler. |
void |
writeMessage(String message)
Writes the error message using the defined Writer. |
void |
writeStatus(String message)
Display an informational message given a message String, using the defined Writer. |
| Field Detail |
|---|
static final String MSG_PROPERTY_PFX
static final String MESSAGE_VERBOSE
static final String LOG_FEATURE_PFX
static final String LOG_LEVEL
static final int OK
static final int LOCALIZE
static final int DEBUG
static final int LOG
static final int INFO
static final int NOTICE
static final int WARN
static final int ERROR
static final int FATAL
static final int OFF
| Method Detail |
|---|
void registerListener(MessageWriter msgwriter)
void writeStatus(String message)
This is also a MessageWriter API method.
String writeMessage(int status,
String message)
MessageHandler.
This is also a MessageWriter API method.
void writeMessage(String message)
This is also a MessageWriter API method.
void printStackTrace(Throwable throwable)
Writer getWriter()
Clock getClock()
String localize(String id)
id - the MessageId within the ListResourceBundle Messages.
String localize(String id,
String arg1)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.
String localize(String id,
String arg1,
String arg2)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.
String localize(String id,
String arg1,
String arg2,
String arg3)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.
String localize(String id,
String arg1,
String arg2,
String arg3,
String arg4)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.arg4 - argument substituting %4 in the message string.
String localize(String id,
String arg1,
String arg2,
String arg3,
String arg4,
String arg5)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.arg4 - argument substituting %4 in the message string.arg5 - argument substituting %5 in the message string.
String localize(String id,
String arg1,
String arg2,
String arg3,
String arg4,
String arg5,
String arg6)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.arg4 - argument substituting %4 in the message string.arg5 - argument substituting %5 in the message string.arg6 - argument substituting %5 in the message string.
String log(String message)
message - the message to be written to the log file.
String log(String timeStamp,
String id)
timeStamp - the optional time stamp string to be added to the log.id - the String or the ID of the message to be written to the log file.
String log(String timeStamp,
String id,
String arg1)
timeStamp - the optional time stamp string to be added to the log.id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.
String log(String timeStamp,
String id,
String arg1,
String arg2)
timeStamp - the optional time stamp string to be added to the log.id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.
String log(String timeStamp,
String id,
String arg1,
String arg2,
String arg3)
timeStamp - the optional time stamp string to be added to the log.id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.
String log(String timeStamp,
String id,
String arg1,
String arg2,
String arg3,
String arg4)
timeStamp - the optional time stamp string to be added to the log.id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.arg4 - argument substituting %4 in the message string.
void status(String id)
id - the MessageId within the ListResourceBundle Messages.
void status(String id,
String arg1)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.
void status(String id,
String arg1,
String arg2)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.
void status(String id,
String arg1,
String arg2,
String arg3)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.
void status(String id,
String arg1,
String arg2,
String arg3,
String arg4)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.arg4 - argument substituting %4 in the message string.String message(String id)
id - the MessageId within the ListResourceBundle Messages.
String message(String id,
String arg1)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.
String message(String id,
String arg1,
String arg2)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.
String message(String id,
String arg1,
String arg2,
String arg3)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.
String message(String id,
String arg1,
String arg2,
String arg3,
String arg4)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.arg4 - argument substituting %4 in the message string.
String notice(String id)
id - the MessageId within the ListResourceBundle Messages.
String notice(String id,
String arg1)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.
String notice(String id,
String arg1,
String arg2)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.
String notice(String id,
String arg1,
String arg2,
String arg3)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.
String notice(String id,
String arg1,
String arg2,
String arg3,
String arg4)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.arg4 - argument substituting %4 in the message string.
String warning(String id)
id - the MessageId within the ListResourceBundle Messages.
String warning(Exception exception)
exception - the tunneled Exception.
String warning(String id,
String arg1)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.
String warning(String id,
String arg1,
String arg2)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.
String warning(String id,
String arg1,
String arg2,
String arg3)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.
String error(String id)
id - the MessageId within the ListResourceBundle Messages.
String error(Exception exception)
exception - the tunneled Exception.
String error(String id,
Exception exception)
id - the MessageId within the ListResourceBundle Messages.exception - the tunneled Exception.
String error(String id,
String arg)
id - the MessageId within the ListResourceBundle Messages.arg - argument substituting %1 in the message string.
String error(String id,
String arg,
Exception exception)
id - the MessageId within the ListResourceBundle Messages.arg - argument substituting %1 in the message string.exception - the tunneled Exception.
String error(String id,
String arg1,
String arg2)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.
String error(String id,
String arg1,
String arg2,
String arg3)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.arg3 - argument substituting %3 in the message string.
String error(String id,
String arg1,
String arg2,
Exception exception)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.exception - the tunneled Exception.
String fatalError(Exception exception)
exception - the tunneled Exception.
String fatalError(Error error)
error - the Error thrown.
String fatalError(String id)
id - the MessageId within the ListResourceBundle Messages.
String fatalError(String id,
Exception exception)
id - the MessageId within the ListResourceBundle Messages.exception - the tunneled Exception.
String fatalError(String id,
String arg1)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.
String fatalError(String id,
String arg1,
Exception exception)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.exception - the tunneled Exception.
String fatalError(String id,
String arg1,
String arg2)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.
String fatalError(String id,
String arg1,
String arg2,
Exception exception)
id - the MessageId within the ListResourceBundle Messages.arg1 - argument substituting %1 in the message string.arg2 - argument substituting %2 in the message string.exception - the tunneled Exception.
void active()
void reset()
int getStatus()
String getStatusText(int status)
This is a MessageHandler API method.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||