本文整理匯總了Java中org.springframework.context.MessageSourceResolvable.getDefaultMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageSourceResolvable.getDefaultMessage方法的具體用法?Java MessageSourceResolvable.getDefaultMessage怎麽用?Java MessageSourceResolvable.getDefaultMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.MessageSourceResolvable
的用法示例。
在下文中一共展示了MessageSourceResolvable.getDefaultMessage方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMessage
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
@Override
public final String getMessage(MessageSourceResolvable resolvable, Locale locale)
throws NoSuchMessageException {
String[] codes = resolvable.getCodes();
if (codes == null) {
codes = new String[0];
}
for (String code : codes) {
String msg = getMessageInternal(code, resolvable.getArguments(), locale);
if (msg != null) {
return msg;
}
}
String defaultMessage = resolvable.getDefaultMessage();
if (defaultMessage != null) {
return renderDefaultMessage(defaultMessage, resolvable.getArguments(), locale);
}
if (codes.length > 0) {
String fallback = getDefaultMessage(codes[0]);
if (fallback != null) {
return fallback;
}
}
throw new NoSuchMessageException(codes.length > 0 ? codes[codes.length - 1] : null, locale);
}
示例2: getMessage
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
@Override
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
Validate.notNull(resolvable, "Message source resolvable must not be null");
for (String code : resolvable.getCodes()) {
String msg = localizationService.translate(code, resolvable.getArguments(), locale);
if (msg != null) {
return msg;
}
}
if (resolvable.getDefaultMessage() != null) {
return resolvable.getDefaultMessage();
}
throw new NoSuchMessageException("Can't resolve message: " + resolvable);
}
示例3: getMessage
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
public final String getMessage(MessageSourceResolvable resolvable, Locale locale)
throws NoSuchMessageException {
String[] codes = resolvable.getCodes();
if (codes == null) {
codes = new String[0];
}
for (String code : codes) {
String msg = getMessageInternal(code, resolvable.getArguments(), locale);
if (msg != null) {
return msg;
}
}
String defaultMessage = resolvable.getDefaultMessage();
if (defaultMessage != null) {
return renderDefaultMessage(defaultMessage, resolvable.getArguments(), locale);
}
if (codes.length > 0) {
String fallback = getDefaultMessage(codes[0]);
if (fallback != null) {
return fallback;
}
}
throw new NoSuchMessageException(codes.length > 0 ? codes[codes.length - 1] : null, locale);
}
示例4: getMessage
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
@Override
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
if (this.parentMessageSource != null) {
return this.parentMessageSource.getMessage(resolvable, locale);
}
else {
if (resolvable.getDefaultMessage() != null) {
return renderDefaultMessage(resolvable.getDefaultMessage(), resolvable.getArguments(), locale);
}
String[] codes = resolvable.getCodes();
String code = (codes != null && codes.length > 0 ? codes[0] : null);
throw new NoSuchMessageException(code, locale);
}
}
示例5: getMessage
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public String getMessage(MessageSourceResolvable resolvable, Locale locale)
throws NoSuchMessageException {
for (String code : resolvable.getCodes()) {
String message = getMessage(code, resolvable.getArguments(), locale);
if (message != null && message.length() > 0) {
return message;
}
}
return resolvable.getDefaultMessage();
}
示例6: resolveArguments
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
private Object[] resolveArguments(Object[] arguments) {
if (arguments == null || arguments.length == 0) {
return arguments;
}
for (int i = 0; i < arguments.length; i++) {
Object arg = arguments[i];
if (arg instanceof MessageSourceResolvable) {
MessageSourceResolvable resolvable = (MessageSourceResolvable)arg;
String[] codes = resolvable.getCodes();
boolean resolved = false;
if (this.messageResources != null) {
for (int j = 0; j < codes.length; j++) {
String code = codes[j];
if (this.messageResources.isPresent(this.locale, code)) {
arguments[i] = this.messageResources.getMessage(
this.locale, code, resolveArguments(resolvable.getArguments()));
resolved = true;
break;
}
}
}
if (!resolved) {
arguments[i] = resolvable.getDefaultMessage();
}
}
}
return arguments;
}
示例7: getMessage
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
if (this.parentMessageSource != null) {
return this.parentMessageSource.getMessage(resolvable, locale);
}
else {
if (resolvable.getDefaultMessage() != null) {
return renderDefaultMessage(resolvable.getDefaultMessage(), resolvable.getArguments(), locale);
}
String[] codes = resolvable.getCodes();
String code = (codes != null && codes.length > 0 ? codes[0] : null);
throw new NoSuchMessageException(code, locale);
}
}
示例8: find
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
/**
* 指定されたロケールから、複數のメッセージキーより該當する値を検索します。
* もし対応するキー値が存在しない場合は、デフォルトメッセージが返卻されます。
* @param context {@link MessageSourceResolvable}
* @param locale ロケール
* @return キーに対応する値
*/
public static String find(MessageSourceResolvable context, Locale locale) {
try {
MessageSource source = MessageSourceLocator.get();
Locale currentLocale = locale;
if (currentLocale == null) {
Locale userLocale = LocaleContextHolder.getLocale();
currentLocale = userLocale != null ? userLocale : Locale.getDefault();
}
return source.getMessage(context, currentLocale);
} catch (NoSuchMessageException e) {
return context.getDefaultMessage();
}
}
示例9: getMessage
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
@Override
public final String getMessage(MessageSourceResolvable resolvable, Locale locale)
throws NoSuchMessageException {
String[] codes = resolvable.getCodes();
if (codes == null) {
codes = new String[0];
}
ICUMessageArguments args = new ICUListMessageArguments(resolvable.getArguments());
for (String code : codes) {
String msg = getMessageInternal(code, args, locale);
if (msg != null) {
return msg;
}
}
String defaultMessage = resolvable.getDefaultMessage();
if (defaultMessage != null) {
return renderDefaultMessage(defaultMessage, args, locale);
}
if (codes.length > 0) {
String fallback = getDefaultMessage(codes[0]);
if (fallback != null) {
return fallback;
}
}
throw new NoSuchMessageException(codes.length > 0 ? codes[codes.length - 1] : null, locale);
}
示例10: getMessage
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
@Override
@Deprecated
public String getMessage(MessageSourceResolvable source) {
return source.getDefaultMessage();
}
示例11: DefaultMessageSourceResolvable
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
/**
* Copy constructor: Create a new instance from another resolvable.
* @param resolvable the resolvable to copy from
*/
public DefaultMessageSourceResolvable(MessageSourceResolvable resolvable) {
this(resolvable.getCodes(), resolvable.getArguments(), resolvable.getDefaultMessage());
}
示例12: getMessage
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
/**
* A workaround for the old code.
*
* @param x
* @return x.getDefaultMessage()
*/
@Deprecated
public String getMessage(MessageSourceResolvable x) {
return x.getDefaultMessage();
}