FileDocCategorySizeDatePackage
Formatter.javaAPI DocAndroid 1.5 API4668Wed May 06 22:41:04 BST 2009java.util.logging

Formatter

public abstract class Formatter extends Object
{@code Formatter} objects are used to format {@link LogRecord} objects into a string representation. Head and tail strings are sometimes used to wrap a set of records. The {@code getHead} and {@code getTail} methods are used for this purpose.
since
Android 1.0

Fields Summary
Constructors Summary
protected Formatter()
Constructs a {@code Formatter} object.

since
Android 1.0

        super();
    
Methods Summary
public abstract java.lang.Stringformat(java.util.logging.LogRecord r)
Converts a {@link LogRecord} object into a string representation. The resulted string is usually localized and includes the message field of the record.

param
r the log record to be formatted into a string.
return
the formatted string.
since
Android 1.0

public java.lang.StringformatMessage(java.util.logging.LogRecord r)
Formats a {@code LogRecord} object into a localized string representation. This is a convenience method for subclasses of {@code Formatter}.

The message string is firstly localized using the {@code ResourceBundle} object associated with the supplied {@code LogRecord}.

Notice : if message contains "{0", then java.text.MessageFormat is used. Otherwise no formatting is performed.

param
r the log record to be formatted.
return
the string resulted from the formatting.
since
Android 1.0

        String pattern = r.getMessage();
        ResourceBundle rb = null;
        // try to localize the message string first
        if (null != (rb = r.getResourceBundle())) {
            try {
                pattern = rb.getString(pattern);
            } catch (Exception e) {
                pattern = r.getMessage();
            }
        }
        if (null != pattern) {
            Object[] params = r.getParameters();
            /*
             * if the message contains "{0", use java.text.MessageFormat to
             * format the string
             */
            if (pattern.indexOf("{0") >= 0 && null != params //$NON-NLS-1$
                    && params.length > 0) {
                try {
                    pattern = MessageFormat.format(pattern, params);
                } catch (IllegalArgumentException e) {
                    pattern = r.getMessage();
                }
            }
        }
        return pattern;
    
public java.lang.StringgetHead(java.util.logging.Handler h)
Gets the head string used to wrap a set of log records. This base class always returns an empty string.

param
h the target handler.
return
the head string used to wrap a set of log records, empty in this implementation.
since
Android 1.0

        return ""; //$NON-NLS-1$
    
public java.lang.StringgetTail(java.util.logging.Handler h)
Gets the tail string used to wrap a set of log records. This base class always returns the empty string.

param
h the target handler.
return
the tail string used to wrap a set of log records, empty in this implementation.
since
Android 1.0

        return ""; //$NON-NLS-1$