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


Java MessageSourceResolvable.getDefaultMessage方法代碼示例

本文整理匯總了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);
}
 
開發者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: 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();
    }
}
 
開發者ID:ctc-g,項目名稱:sinavi-jfw,代碼行數:21,代碼來源:Rs.java

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

示例10: getMessage

import org.springframework.context.MessageSourceResolvable; //導入方法依賴的package包/類
@Override
@Deprecated
public String getMessage(MessageSourceResolvable source) {
	return source.getDefaultMessage();
}
 
開發者ID:BrainTech,項目名稱:svarog,代碼行數:6,代碼來源:SvarogI18n.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

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


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