1 7 8 9 package java.util.logging; 10 11 25 26 public abstract class Formatter { 27 28 31 protected Formatter() { 32 } 33 34 45 public abstract String format(LogRecord record); 46 47 48 57 public String getHead(Handler h) { 58 return ""; 59 } 60 61 70 public String getTail(Handler h) { 71 return ""; 72 } 73 74 75 96 public synchronized String formatMessage(LogRecord record) { 97 String format = record.getMessage(); 98 java.util.ResourceBundle catalog = record.getResourceBundle(); 99 if (catalog != null) { 100 try { 108 format = catalog.getString(record.getMessage()); 109 } catch (java.util.MissingResourceException ex) { 110 format = record.getMessage(); 112 } 113 } 116 try { 118 Object parameters[] = record.getParameters(); 119 if (parameters == null || parameters.length == 0) { 120 return format; 122 } 123 if (format.indexOf("{0") >= 0 || format.indexOf("{1") >=0 || 129 format.indexOf("{2") >=0|| format.indexOf("{3") >=0) { 130 return java.text.MessageFormat.format(format, parameters); 131 } 132 return format; 133 134 } catch (Exception ex) { 135 return format; 137 } 138 } 139 } 140 141 142 143 | Popular Tags |