servletlabellocator.java

来自「非常接近C/S操作方式的Java Ajax框架-ZK 用ZK框架使你的B/S应」· Java 代码 · 共 60 行

JAVA
60
字号
/* ServletLabelLocator.java{{IS_NOTE	Purpose:			Description:			History:		Sat Apr  8 19:51:08     2006, Created by tomyeh}}IS_NOTECopyright (C) 2006 Potix Corporation. All Rights Reserved.{{IS_RIGHT	This program is distributed under GPL Version 2.0 in the hope that	it will be useful, but WITHOUT ANY WARRANTY.}}IS_RIGHT*/package org.zkoss.web.util.resource;import java.util.Locale;import java.io.IOException;import java.net.URL;import javax.servlet.ServletContext;import org.zkoss.util.resource.LabelLocator;/** * Used by Lables to load labels from a servlet context. * * @author tomyeh */public class ServletLabelLocator implements LabelLocator {	private final ServletContext _ctx;	public ServletLabelLocator(ServletContext ctx) {		if (ctx == null)			throw new IllegalArgumentException("null");		_ctx = ctx;	}	//-- LabelLocator --//	public URL locate(Locale locale) throws IOException {		return _ctx.getResource("/WEB-INF/"+getI3LabelName(locale));	}	/** Returns the filename of i3-label.properties. */	private static final String getI3LabelName(Locale locale) {		return locale.equals(Locale.ENGLISH) ?			"i3-label.properties": "i3-label_" + locale + ".properties";	}	//-- Object --//	public int hashCode() {		return _ctx.hashCode();	}	public boolean equals(Object o) {		return o instanceof ServletLabelLocator			&& ((ServletLabelLocator)o)._ctx.equals(_ctx);	}}

⌨️ 快捷键说明

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