當前位置: 首頁>>代碼示例>>Java>>正文


Java MessageSourceResolvable.getCodes方法代碼示例

本文整理匯總了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);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:AbstractMessageSource.java

示例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);
}
 
開發者ID:Evolveum,項目名稱:midpoint,代碼行數:18,代碼來源:LocalizationMessageSource.java

示例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);
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:26,代碼來源:AbstractMessageSource.java

示例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);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:15,代碼來源:DelegatingMessageSource.java

示例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();
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:14,代碼來源:ResourceBundleManagerMessageSource.java

示例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;
}
 
開發者ID:Gert-Jan1966,項目名稱:spring-struts-forwardport,代碼行數:29,代碼來源:SpringBindingActionForm.java

示例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);
	}
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:14,代碼來源:DelegatingMessageSource.java

示例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);
}
 
開發者ID:agwlvssainokuni,項目名稱:springapp,代碼行數:13,代碼來源:DeindexMessageSource.java

示例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;
}
 
開發者ID:agwlvssainokuni,項目名稱:springapp,代碼行數:11,代碼來源:ResponseHelperImpl.java

示例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);
}
 
開發者ID:mochalov,項目名稱:grails-icu,代碼行數:28,代碼來源:ICUAbstractMessageSource.java

示例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());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:8,代碼來源:DefaultMessageSourceResolvable.java


注:本文中的org.springframework.context.MessageSourceResolvable.getCodes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。