⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 butormessageresources.java

📁 一个实用工具类
💻 JAVA
字号:
/* * Copyright (C) butor.com. All rights reserved. * * This software is published under the terms of the GNU Library General * Public License (GNU LGPL), a copy of which has been included with this * distribution in the LICENSE.txt file.  */package org.butor.web.helper;import java.util.Locale;import org.apache.struts.util.MessageResources;import org.apache.struts.util.MessageResourcesFactory;import org.butor.messageResources.MessageResourcesService;/** * Concrete subclass of <code>MessageResources</code> that reads message keys * and corresponding strings from named property resources in the same manner * that <code>java.util.PropertyResourceBundle</code> does. Properties files are loaded * from a directory specified by the specified directory in the configuration. * * @author Aiman SAWAN */public class ButorMessageResources extends MessageResources {	/**	 * Construct a new ButorMessageResources according to the	 * specified parameters.	 *	 * @param factory The MessageResourcesFactory that created us	 * @param config The configuration parameter for this MessageResources.	 * 		this is the absolute path where to picks up properties files.	 */	public ButorMessageResources(MessageResourcesFactory factory, String config) {		this(factory, config, false);	}	/**	 * Construct a new ButorMessageResources according to the	 * specified parameters.	 *	 * @param factory The MessageResourcesFactory that created us	 * @param config The configuration parameter for this MessageResources	 * 		this is the absolute path where to picks up properties files.	 * @param returnNull The returnNull property we should initialize with	 */	public ButorMessageResources(		MessageResourcesFactory factory,		String config,		boolean returnNull) {		super(factory, config, returnNull);			}	/**	 * Returns a text message for the specified key, for the default Locale.	 *	 * @param locale The requested message Locale, or <code>null</code>	 *  for the system default Locale	 * @param key The message key to look up	 */	public String getMessage(Locale locale, String key) {		return MessageResourcesService.getMessage(locale, key);	}    /**     * Returns a text message after parametric replacement of the specified     * parameter placeholders.  A null string result will be returned by     * this method if no resource bundle has been configured.     *     * @param locale The requested message Locale, or <code>null</code>     *  for the system default Locale     * @param key The message key to look up     * @param args An array of replacement parameters for placeholders     */    public String getMessage(Locale locale, String key, Object args[]) {		return MessageResourcesService.getMessage(locale, key, args);    }	/**	 * Load the messages associated with the specified Locale key.  For this	 * implementation, the <code>config</code> property should contain an absulte	 * path name where to picks up properties files.	 * 	 * Properties file format is <file name>_<locale key>.properties. All files that	 * match the locale key received in parameter will be loaded in cache.	 *	 * @param localeKey Locale key for the messages to be retrieved	 */	public void loadLocale(String localeKey) {		// overrided to avoid parent with nothing to do. 		// Service do the job.	}    /**     * Return <code>true</code> if there is a defined message for the specified     * key in the specified Locale.     *     * @param locale The requested message Locale, or <code>null</code>     *  for the system default Locale     * @param key The message key to look up     */    public boolean isPresent(Locale locale, String key) {		return MessageResourcesService.exists(locale, key);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -