| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 | |
final static int | EVENT |
final static int | FILE |
final static int | NONE |
final static int | SCREEN |
Method Summary | |
static void | addListener(MessageListener listener) adds a MessageListener which listens for MessageEvents |
static void | error(String errorMessage) error warning for the user |
static void | errorln(String errorMessage) convenience method which adds a return to the error message |
static String | getLogfileName() returns the logfile name |
static int | getOutputMethod() informs what output method is set |
static void | log(String message) informs the user of the message |
static void | logln(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(String filename, boolean append) sets the logfile name |
static void | setOutputMethod(int method) sets the output method |
Field Detail |
public final static int EVENT
public final static int FILE
public final static int NONE
public final static int SCREEN
Method Detail |
public static void addListener(MessageListener listener)
public static void error(String errorMessage)
public static void errorln(String errorMessage)
public static String getLogfileName()
public static int getOutputMethod()
public static void log(String message)
public static void logln(String message)
public static void removeListener(MessageListener listener)
public static void setID(boolean id)
public static void setLogfileName(String filename, boolean append)
public static void setOutputMethod(int method)
Association Links |
to Class java.io.PrintWriter
to Class java.lang.String
to Class java.lang.String
to Class java.util.Vector
| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |