diff --git a/org.springframework.context/src/main/java/org/springframework/context/MessageSourceResolvable.java b/org.springframework.context/src/main/java/org/springframework/context/MessageSourceResolvable.java index d1b1f388d06..b6441e59d72 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/MessageSourceResolvable.java +++ b/org.springframework.context/src/main/java/org/springframework/context/MessageSourceResolvable.java @@ -1,12 +1,12 @@ /* - * Copyright 2002-2006 the original author or authors. - * + * Copyright 2002-2010 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ public interface MessageSourceResolvable { * they should get tried. The last code will therefore be the default one. * @return a String array of codes which are associated with this message */ - public String[] getCodes(); + String[] getCodes(); /** * Return the array of arguments to be used to resolve this message. @@ -42,12 +42,12 @@ public interface MessageSourceResolvable { * placeholders within the message text * @see java.text.MessageFormat */ - public Object[] getArguments(); + Object[] getArguments(); /** * Return the default message to be used to resolve this message. * @return the default message, or null if no default */ - public String getDefaultMessage(); + String getDefaultMessage(); } diff --git a/org.springframework.context/src/main/java/org/springframework/context/support/AbstractMessageSource.java b/org.springframework.context/src/main/java/org/springframework/context/support/AbstractMessageSource.java index edd57230504..3d9231a0fcf 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/support/AbstractMessageSource.java +++ b/org.springframework.context/src/main/java/org/springframework/context/support/AbstractMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -148,8 +148,9 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme return msg; } } - if (resolvable.getDefaultMessage() != null) { - return renderDefaultMessage(resolvable.getDefaultMessage(), resolvable.getArguments(), locale); + String defaultMessage = resolvable.getDefaultMessage(); + if (defaultMessage != null) { + return renderDefaultMessage(defaultMessage, resolvable.getArguments(), locale); } if (codes.length > 0) { String fallback = getDefaultMessage(codes[0]); @@ -256,25 +257,6 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme return null; } - /** - * Render the given default message String. The default message is passed in - * as specified by the caller and can be rendered into a fully formatted - * default message shown to the user. - *

The default implementation passes the String to {@link #formatMessage}, - * resolving any argument placeholders found in them. Subclasses may override - * this method to plug in custom processing of default messages. - * @param defaultMessage the passed-in default message String - * @param args array of arguments that will be filled in for params within - * the message, or null if none. - * @param locale the Locale used for formatting - * @return the rendered default message (with resolved arguments) - * @see #formatMessage(String, Object[], java.util.Locale) - */ - @Override - protected String renderDefaultMessage(String defaultMessage, Object[] args, Locale locale) { - return formatMessage(defaultMessage, args, locale); - } - /** * Searches through the given array of objects, finds any MessageSourceResolvable