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

📄 localesaxhandler.java

📁 为了下东西 随便发了个 datamining 的源代码
💻 JAVA
字号:
/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*
 * Created on 2006/09/02
 *
 * @Author: Xiaojun Chen
 * $Revision$ 1.0
 *
 */

package eti.bi.common.Locale;

import java.util.Hashtable;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class LocaleSAXHandler extends DefaultHandler{
public final static String ELEMENT_WORKSPACE = "Locale";
	
	private static locale temp_locale;
	private Hashtable m_AttrMap;
	private boolean iscurrent;
	private String basePath;
	
	public LocaleSAXHandler(String basePath) {
		this.basePath = basePath;
	}
	
	/* 
	 * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
	 */
	@SuppressWarnings("unchecked")
	public void startElement(
		String aNamespaceURI,
		String aSimpleName,
		String aQualifiedName,
		Attributes aAttrs)
		throws SAXException 
	{
		String aElementName = aSimpleName; // element name
		m_AttrMap = new Hashtable();

		if ("".equals(aElementName)) {
			aElementName = aQualifiedName; // not namespaceAware
		}

		if (aAttrs != null) {
			for (int i = 0; i < aAttrs.getLength(); i++) {
				String aAttrName = aAttrs.getLocalName(i); // Attr name
				if ("".equals(aAttrName))
					aAttrName = aAttrs.getQName(i);
				
				if(aAttrName.equals("current")){
					iscurrent = true;
				}
				else{
					m_AttrMap.put(aAttrName, aAttrs.getValue(i));
				}
			}
		}
		
		if(aElementName.equals(ELEMENT_WORKSPACE)){
			temp_locale = new locale((String)m_AttrMap.get("name"), (String)m_AttrMap.get("localeString"), basePath, (String)m_AttrMap.get("file"), (String)m_AttrMap.get("description"),(String) m_AttrMap.get("charsetName"));
		}
	}
	
	/**
	 * @see org.xml.sax.ContentHandler#endElement(String, String, String)
	 */
	public void endElement(
			String aNamespaceURI,
			String aSimpleName,
			String aQualifiedName)
			throws SAXException 
	{
		String aElementName = aSimpleName; // element name
		if ("".equals(aElementName))
		{
			aElementName = aQualifiedName; // not namespaceAware
		}
		
		if(aElementName.equals(ELEMENT_WORKSPACE)){
			if(iscurrent){
				LocalesLoader.AddLocaleCurrent(temp_locale);
				iscurrent = false;
			}
			else{
				LocalesLoader.AddLocale(temp_locale);
			}
		}
	}
}

⌨️ 快捷键说明

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