src/java.management/share/classes/sun/management/Agent.java

Print this page
rev 10521 : 8055723[core]: Replace concat String to append in StringBuilder parameters
Contributed-by: Otavio Santana <otaviojava@java.net>


 485                 String msg = (ex.getCause() == null
 486                         ? ex.getMessage()
 487                         : ex.getCause().getMessage());
 488                 error(AGENT_CLASS_FAILED, msg);
 489             }
 490         }
 491     }
 492 
 493     public static void error(String key) {
 494         String keyText = getText(key);
 495         System.err.print(getText("agent.err.error") + ": " + keyText);
 496         throw new RuntimeException(keyText);
 497     }
 498 
 499     public static void error(String key, String[] params) {
 500         if (params == null || params.length == 0) {
 501             error(key);
 502         } else {
 503             StringBuilder message = new StringBuilder(params[0]);
 504             for (int i = 1; i < params.length; i++) {
 505                 message.append(" " + params[i]);
 506             }
 507             error(key, message.toString());
 508         }
 509     }
 510 
 511     public static void error(String key, String message) {
 512         String keyText = getText(key);
 513         System.err.print(getText("agent.err.error") + ": " + keyText);
 514         System.err.println(": " + message);
 515         throw new RuntimeException(keyText + ": " + message);
 516     }
 517 
 518     public static void error(Exception e) {
 519         e.printStackTrace();
 520         System.err.println(getText(AGENT_EXCEPTION) + ": " + e.toString());
 521         throw new RuntimeException(e);
 522     }
 523 
 524     public static void warning(String key, String message) {
 525         System.err.print(getText("agent.err.warning") + ": " + getText(key));




 485                 String msg = (ex.getCause() == null
 486                         ? ex.getMessage()
 487                         : ex.getCause().getMessage());
 488                 error(AGENT_CLASS_FAILED, msg);
 489             }
 490         }
 491     }
 492 
 493     public static void error(String key) {
 494         String keyText = getText(key);
 495         System.err.print(getText("agent.err.error") + ": " + keyText);
 496         throw new RuntimeException(keyText);
 497     }
 498 
 499     public static void error(String key, String[] params) {
 500         if (params == null || params.length == 0) {
 501             error(key);
 502         } else {
 503             StringBuilder message = new StringBuilder(params[0]);
 504             for (int i = 1; i < params.length; i++) {
 505                 message.append(' ').append(params[i]);
 506             }
 507             error(key, message.toString());
 508         }
 509     }
 510 
 511     public static void error(String key, String message) {
 512         String keyText = getText(key);
 513         System.err.print(getText("agent.err.error") + ": " + keyText);
 514         System.err.println(": " + message);
 515         throw new RuntimeException(keyText + ": " + message);
 516     }
 517 
 518     public static void error(Exception e) {
 519         e.printStackTrace();
 520         System.err.println(getText(AGENT_EXCEPTION) + ": " + e.toString());
 521         throw new RuntimeException(e);
 522     }
 523 
 524     public static void warning(String key, String message) {
 525         System.err.print(getText("agent.err.warning") + ": " + getText(key));