1 16 package org.jmanage.core.util; 17 18 import java.util.Properties ; 19 import java.util.logging.Logger ; 20 import java.util.logging.Level ; 21 import java.io.FileInputStream ; 22 import java.io.IOException ; 23 import java.text.MessageFormat ; 24 25 30 public class ErrorCatalog { 31 32 private static final Logger logger = Loggers.getLogger(ErrorCatalog.class); 33 34 private static final Properties errorMap; 35 36 static{ 37 final String errorProperties = CoreUtils.getConfigDir() + 38 "/errors.properties"; 39 errorMap = new Properties (); 40 try { 41 errorMap.load(new FileInputStream (errorProperties)); 42 } catch (IOException e) { 43 logger.log(Level.WARNING, "Error reading " + 44 errorProperties + ". error: " + e.getMessage()); 45 } 46 } 47 48 public static String getMessage(String errorCode){ 49 return getMessage(errorCode, null); 50 } 51 52 public static String getMessage(String errorCode, Object value0){ 53 return getMessage(errorCode, new Object []{value0}); 54 } 55 56 public static String getMessage(String errorCode, Object [] values){ 57 String message = errorMap.getProperty(errorCode, 58 "ErrorCode=" + errorCode); 59 if(values != null){ 60 message = MessageFormat.format(message, values); 61 } 62 return message; 63 } 64 } 65 | Popular Tags |