2362N/A * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A Formatter provides support for formatting LogRecords. 0N/A * Typically each logging Handler will have a Formatter associated 0N/A * with it. The Formatter takes a LogRecord and converts it to 0N/A * Some formatters (such as the XMLFormatter) need to wrap head 0N/A * and tail strings around a set of formatted records. The getHeader 0N/A * and getTail methods can be used to obtain these strings. 0N/A * Construct a new formatter. 0N/A * Format the given log record and return the formatted string. 0N/A * The resulting formatted String will normally include a 1664N/A * localized and formatted version of the LogRecord's message field. 0N/A * It is recommended to use the {@link Formatter#formatMessage} 0N/A * convenience method to localize and format the message field. 0N/A * @param record the log record to be formatted. 0N/A * @return the formatted log record 0N/A * Return the header string for a set of formatted records. 0N/A * This base class returns an empty string, but this may be 1664N/A * overridden by subclasses. 0N/A * @param h The target handler (can be null) 0N/A * @return header string 0N/A * Return the tail string for a set of formatted records. 0N/A * This base class returns an empty string, but this may be 1664N/A * overridden by subclasses. 0N/A * @param h The target handler (can be null) 0N/A * @return tail string 0N/A * Localize and format the message string from a log record. This 0N/A * method is provided as a convenience for Formatter subclasses to 0N/A * use when they are performing formatting. 0N/A * The message string is first localized to a format string using 0N/A * the record's ResourceBundle. (If there is no ResourceBundle, 0N/A * or if the message key is not found, then the key is used as the 0N/A * format string.) The format String uses java.text style 0N/A * <li>If there are no parameters, no formatter is used. 0N/A * <li>Otherwise, if the string contains "{0" then 0N/A * java.text.MessageFormat is used to format the string. 0N/A * <li>Otherwise no formatting is performed. 0N/A * @param record the log record containing the raw message 0N/A * @return a localized and formatted message 0N/A // Drop through. Use record message as format 0N/A // Do the formatting. 0N/A // No parameters. Just return format string. 0N/A // Is it a java.text style format? 0N/A // Ideally we could match with 0N/A // Pattern.compile("\\{\\d").matcher(format).find()) 0N/A // However the cost is 14% higher, so we cheaply check for 0N/A // 1 of the first 4 parameters 0N/A // Formatting failed: use localized format string.