|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.fop.messaging.MessageHandler
The class MessageHandler contains the static methods log and error which
should be used for any end user information instead of System.out.print() or
System.err.print(). The class defines several output methods:
writing to the screen (default), logging to a file, creating message events and repressing all
output. If you don't want to change the default behaviour, you should be
happy with MessageHandler.log(message) and MessageHandler.error(message)
The class MessageHandler also supports the setting of an id. If set every message
has as a prefix an identifying string. That way Fop probably can also be used in
environments, where more than one Fop instance are running in same JVM.
If Fop is embedded in a gui application or for any reasons the existing
messaging system doesn't meet the programmer's requirements, one can add
a MessageEvent listener to MessageHandler and handle the incoming messages
in an appropriate way. See the class DefaultMessageListener, which is a trivial
implementation of the MessageListener.
Here is an example how to configure MessageHandler for the DefaultMessageListener (anybody
can provide his own listener by extending MessageListener
MessageHandler.setOutputMethod(MessageHandler.EVENT);
MessageHandler.addListener(new DefaultMessageListener());
This examples shows, how to redirect the messages to a log file called fop.log.
All messages are appended to this file.
MessageHandler.setOutputMethod(MessageHandler.FILE);
MessageHandler.setLogfileName("\\fop.log",true);
Field Summary | |
---|---|
static int |
EVENT
|
static int |
FILE
|
static int |
NONE
|
static int |
SCREEN
|
Constructor Summary | |
---|---|
MessageHandler()
|
Method Summary | |
---|---|
static void |
addListener(MessageListener listener)
adds a MessageListener which listens for MessageEvents |
static void |
error(java.lang.String errorMessage)
error warning for the user |
static void |
errorln(java.lang.String errorMessage)
convenience method which adds a return to the error message |
static java.lang.String |
getLogfileName()
returns the logfile name |
static int |
getOutputMethod()
informs what output method is set |
static void |
log(java.lang.String message)
informs the user of the message |
static void |
logln(java.lang.String message)
convenience method which adds a return to the message |
static void |
removeListener(MessageListener listener)
removes a MessageListener |
static void |
setID(boolean id)
if set to true an id string is prefixed to every message uses the thread info as an id for the message producer. |
static void |
setLogfileName(java.lang.String filename,
boolean append)
sets the logfile name |
static void |
setOutputMethod(int method)
sets the output method |
static void |
setQuiet(boolean quietMode)
if set to true all normal messages are suppressed. |
static void |
setScreenLogger(org.apache.avalon.framework.logger.Logger newLogger)
Sets the Logger used for the screen output method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SCREEN
public static final int FILE
public static final int EVENT
public static final int NONE
Constructor Detail |
public MessageHandler()
Method Detail |
public static void log(java.lang.String message)
message
- the message for the userpublic static void logln(java.lang.String message)
message
- the message for the userpublic static void error(java.lang.String errorMessage)
errorMessage
- contains the warning stringpublic static void errorln(java.lang.String errorMessage)
errorMessage
- the message for the userpublic static void addListener(MessageListener listener)
public static void removeListener(MessageListener listener)
public static void setScreenLogger(org.apache.avalon.framework.logger.Logger newLogger)
newLogger
- a logger for screen output. This may not be null.public static void setOutputMethod(int method)
method
- the output method to use, allowed values arepublic static int getOutputMethod()
public static void setLogfileName(java.lang.String filename, boolean append)
filename
- name of the logfileappend
- if true, the logfile is appendedpublic static java.lang.String getLogfileName()
public static void setID(boolean id)
id
- boolean (default is false)public static void setQuiet(boolean quietMode)
quietMode
- boolean (default is false)
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |