Package java.util.logging
Class Formatter
- java.lang.Object
-
- java.util.logging.Formatter
-
- Direct Known Subclasses:
SimpleFormatter,XMLFormatter
public abstract class Formatter extends Object
Formatterobjects are used to formatLogRecordobjects into a string representation. Head and tail strings are sometimes used to wrap a set of records. ThegetHeadandgetTailmethods are used for this purpose.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFormatter()Constructs aFormatterobject.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Stringformat(LogRecord r)Converts aLogRecordobject into a string representation.StringformatMessage(LogRecord r)Formats aLogRecordobject into a localized string representation.StringgetHead(Handler h)Gets the head string used to wrap a set of log records.StringgetTail(Handler h)Gets the tail string used to wrap a set of log records.
-
-
-
Method Detail
-
format
public abstract String format(LogRecord r)
Converts aLogRecordobject into a string representation. The resulted string is usually localized and includes the message field of the record.- Parameters:
r- the log record to be formatted into a string.- Returns:
- the formatted string.
-
formatMessage
public String formatMessage(LogRecord r)
Formats aLogRecordobject into a localized string representation. This is a convenience method for subclasses ofFormatter.The message string is firstly localized using the
ResourceBundleobject associated with the suppliedLogRecord.Notice : if message contains "{0", then java.text.MessageFormat is used. Otherwise no formatting is performed.
- Parameters:
r- the log record to be formatted.- Returns:
- the string resulted from the formatting.
-
getHead
public String getHead(Handler h)
Gets the head string used to wrap a set of log records. This base class always returns an empty string.- Parameters:
h- the target handler.- Returns:
- the head string used to wrap a set of log records, empty in this implementation.
-
-