|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.logging.Formatter
public abstract class Formatter
A Formatter
supports handlers by localizing
message texts and by subsituting parameter values for their
placeholders.
Constructor Summary | |
---|---|
protected |
Formatter()
Constructs a new Formatter. |
Method Summary | |
---|---|
abstract String |
format(LogRecord record)
Formats a LogRecord into a string. |
String |
formatMessage(LogRecord record)
Formats the message part of a log record. |
String |
getHead(Handler handler)
Returns a string that handlers are supposed to emit before the first log record. |
String |
getTail(Handler handler)
Returns a string that handlers are supposed to emit after the last log record. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Formatter()
Method Detail |
---|
public abstract String format(LogRecord record)
record
- the log record for which a string form is requested.public String getHead(Handler handler)
XMLFormatter
override this method in order to provide a suitable header.
handler
- the handler which will prepend the returned
string in front of the first log record. This method
may inspect certain properties of the handler, for
example its encoding, in order to construct the header.
public String getTail(Handler handler)
XMLFormatter
override this method in order to provide a suitable tail.
handler
- the handler which will append the returned
string after the last log record. This method
may inspect certain properties of the handler
in order to construct the tail.
public String formatMessage(LogRecord record)
First, the Formatter localizes the record message to the default locale by looking up the message in the record's localization resource bundle. If this step fails because there is no resource bundle associated with the record, or because the record message is not a key in the bundle, the raw message is used instead.
Second, the Formatter substitutes appropriate strings for
the message parameters. If the record returns a non-empty
array for getParameters()
and the localized
message string contains the character sequence "{0", the
formatter uses java.text.MessageFormat
to format
the message. Otherwise, no parameter substitution is performed.
record
- the log record to be localized and formatted.
NullPointerException
- if record
is null
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |