本文整理匯總了Java中org.springframework.context.MessageSourceResolvable.getCodes方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageSourceResolvable.getCodes方法的具體用法?Java MessageSourceResolvable.getCodes怎麽用?Java MessageSourceResolvable.getCodes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.MessageSourceResolvable
的用法示例。
在下文中一共展示了MessageSourceResolvable.getCodes方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: getMessage
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
@Override
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
for (String code : resolvable.getCodes()) {
try {
return messageSource.getMessage(
parse2(code, resolvable.getArguments(), resolvable.getDefaultMessage()), locale);
} catch (NoSuchMessageException ex) {
// NOTHING
}
}
throw new NoSuchMessageException(resolvable.getCodes().length <= 0 ? null : resolvable.getCodes()[0], locale);
}
示例9: getMessageList
import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
private List<Response.Item> getMessageList(List<? extends MessageSourceResolvable> messages) {
Locale locale = LocaleContextHolder.getLocale();
List<Response.Item> list = new ArrayList<>(messages.size());
for (MessageSourceResolvable resolvable : messages) {
String code = resolvable.getCodes()[resolvable.getCodes().length - 1];
String message = messageSource.getMessage(resolvable, locale);
list.add(new Response.Item(code, message));
}
return list;
}
示例10: 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);
}
示例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());
}