J2ME核心类及MIDlet类 MIDP用户界面对象 图形处理及低级事件处理 多线程编程 I/O及网络编程 数据库RMS编程 浮点数编程 多媒体及GAME API编程 安全、加密及

源代码在线查看: prefixmap.java

软件大小: 3868 K
上传用户: lingyun579
关键词: MIDlet J2ME GAME MIDP
下载地址: 免注册下载 普通下载 VIP

相关代码

				package org.kxml;								import java.util.*;								/** Like Attribute, this class is immutable for similar reasons */								public class PrefixMap {								    Hashtable prefixMap;				    Hashtable namespaceMap;								    public PrefixMap () {					prefixMap = new Hashtable ();					namespaceMap = new Hashtable ();				    }												    public PrefixMap (PrefixMap base, String prefix, String namespace) {       					if (base == null) {					    prefixMap = new Hashtable ();					    namespaceMap = new Hashtable ();					}					else {					    prefixMap = clone (base.prefixMap);					    namespaceMap = clone (base.namespaceMap);					}										if (namespace == null) namespace = "";					String oldNS = (String) prefixMap.get (prefix);					if (oldNS == null) oldNS = "";										if (!namespace.equals (oldNS)) {					    					    if (prefix.equals (namespaceMap.get (oldNS))) 						namespaceMap.remove (oldNS);					    					    prefixMap.put (prefix, namespace);					    namespaceMap.put (namespace, prefix);					}				    } 												    private static Hashtable clone (Hashtable original) {									Hashtable copy = new Hashtable (original.size () + 1);					for (Enumeration e = original.keys (); e.hasMoreElements ();) {					    Object key = e.nextElement ();					    copy.put (key, original.get (key));					}					return copy;				    }												    /** returns the namespace associated with the given prefix,					or null, if none is assigned */								    public String getNamespace (String prefix) {					return (String) prefixMap.get (prefix);					//	String namespace = (String) prefixMap.get (prefix);					//	return namespace == null ? Xml.NO_NAMESPACE : namespace;				    }												    public String getPrefix (String namespace) {					return (String) namespaceMap.get 					    (namespace == null ? "" : namespace);				    }												    public Enumeration prefixEnumeration () {					return prefixMap.keys ();				    }				}											

相关资源