1 16 17 package org.springframework.context.support; 18 19 import java.text.MessageFormat ; 20 import java.util.HashMap ; 21 import java.util.Locale ; 22 import java.util.Map ; 23 24 34 public class StaticMessageSource extends AbstractMessageSource { 35 36 37 private final Map messages = new HashMap (); 38 39 40 protected MessageFormat resolveCode(String code, Locale locale) { 41 return (MessageFormat ) this.messages.get(code + "_" + locale.toString()); 42 } 43 44 50 public void addMessage(String code, Locale locale, String msg) { 51 this.messages.put(code + "_" + locale.toString(), createMessageFormat(msg, locale)); 52 if (logger.isDebugEnabled()) { 53 logger.debug("Added message [" + msg + "] for code [" + code + "] and Locale [" + locale + "]"); 54 } 55 } 56 57 58 public String toString() { 59 return getClass().getName() + ": " + this.messages; 60 } 61 62 } 63 | Popular Tags |