88 return "";
89 }
90
91
92 /**
93 * Localize and format the message string from a log record. This
94 * method is provided as a convenience for Formatter subclasses to
95 * use when they are performing formatting.
96 * <p>
97 * The message string is first localized to a format string using
98 * the record's ResourceBundle. (If there is no ResourceBundle,
99 * or if the message key is not found, then the key is used as the
100 * format string.) The format String uses java.text style
101 * formatting.
102 * <ul>
103 * <li>If there are no parameters, no formatter is used.
104 * <li>Otherwise, if the string contains "{0" then
105 * java.text.MessageFormat is used to format the string.
106 * <li>Otherwise no formatting is performed.
107 * </ul>
108 * <p>
109 *
110 * @param record the log record containing the raw message
111 * @return a localized and formatted message
112 */
113 public synchronized String formatMessage(LogRecord record) {
114 String format = record.getMessage();
115 java.util.ResourceBundle catalog = record.getResourceBundle();
116 if (catalog != null) {
117 try {
118 format = catalog.getString(record.getMessage());
119 } catch (java.util.MissingResourceException ex) {
120 // Drop through. Use record message as format
121 format = record.getMessage();
122 }
123 }
124 // Do the formatting.
125 try {
126 Object parameters[] = record.getParameters();
127 if (parameters == null || parameters.length == 0) {
128 // No parameters. Just return format string.
|
88 return "";
89 }
90
91
92 /**
93 * Localize and format the message string from a log record. This
94 * method is provided as a convenience for Formatter subclasses to
95 * use when they are performing formatting.
96 * <p>
97 * The message string is first localized to a format string using
98 * the record's ResourceBundle. (If there is no ResourceBundle,
99 * or if the message key is not found, then the key is used as the
100 * format string.) The format String uses java.text style
101 * formatting.
102 * <ul>
103 * <li>If there are no parameters, no formatter is used.
104 * <li>Otherwise, if the string contains "{0" then
105 * java.text.MessageFormat is used to format the string.
106 * <li>Otherwise no formatting is performed.
107 * </ul>
108 *
109 * @param record the log record containing the raw message
110 * @return a localized and formatted message
111 */
112 public synchronized String formatMessage(LogRecord record) {
113 String format = record.getMessage();
114 java.util.ResourceBundle catalog = record.getResourceBundle();
115 if (catalog != null) {
116 try {
117 format = catalog.getString(record.getMessage());
118 } catch (java.util.MissingResourceException ex) {
119 // Drop through. Use record message as format
120 format = record.getMessage();
121 }
122 }
123 // Do the formatting.
124 try {
125 Object parameters[] = record.getParameters();
126 if (parameters == null || parameters.length == 0) {
127 // No parameters. Just return format string.
|