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

📄 resourcebundlelocalizedstring.java

📁 freemaker安装软件
💻 JAVA
字号:
package freemarker.template;



import java.util.Locale;

import java.util.ResourceBundle;

import java.util.MissingResourceException;



/**

 * A concrete implementation of {@link LocalizedString} that gets 

 * a localized string from a {@link java.util.ResourceBundle}  

 * @author Jonathan Revusky

 */



public class ResourceBundleLocalizedString extends LocalizedString {

	

	private String resourceKey, resourceBundleLookupKey;

	

	/**

	 * @param resourceBundleLookupKey The lookup key for the resource bundle

	 * @param resourceKey the specific resource (assumed to be a string) to fish out of the resource bundle

	 */

	

	public ResourceBundleLocalizedString(String resourceBundleLookupKey, String resourceKey) { 

		this.resourceBundleLookupKey = resourceBundleLookupKey;

		this.resourceKey = resourceKey;

	}



	public String getLocalizedString(Locale locale) throws TemplateModelException {

		try {

			ResourceBundle rb = ResourceBundle.getBundle(resourceBundleLookupKey, locale);

			return rb.getString(resourceKey);

		}

		catch (MissingResourceException mre) {

			throw new TemplateModelException("missing resource", mre);

		}

	}

}

⌨️ 快捷键说明

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