Methods Summary |
---|
public java.lang.String | getCreate(java.lang.String key)Get the namespaace for the given package If there is no entry in the HashMap for
this namespace, create one.
Object value = super.get(key);
if (value == null) {
value = makeNamespaceFromPackageName(key);
put(key, value, null);
}
return (String) value;
|
public java.lang.String | getCreate(java.lang.String key, java.lang.String prefix)Get the namespaace for the given package If there is no entry in the HashMap for
this namespace, create one.
Object value = super.get(key);
if (value == null) {
value = makeNamespaceFromPackageName(key);
put(key, value, prefix);
}
return (String) value;
|
public java.lang.String | getCreatePrefix(java.lang.String namespace)Get the prefix for the given namespace. If one exists, create one
if (namespacePrefixMap.get(namespace) == null) {
namespacePrefixMap.put(namespace, "tns" + prefixCount++);
}
return (String) namespacePrefixMap.get(namespace);
|
public java.util.Iterator | getNamespaces()Get the list of namespaces currently registered
return namespacePrefixMap.keySet().iterator();
|
public static java.lang.String | getPackage(java.lang.String namespace)Reverse the process. Get the package name from the namespace.
try {
URL url = new URL(namespace);
StringTokenizer st = new StringTokenizer(url.getHost(), ".");
String[] words = new String[st.countTokens()];
for (int i = 0; i < words.length; ++i) {
words[i] = st.nextToken();
}
StringBuffer sb = new StringBuffer(80);
for (int i = words.length - 1; i >= 0; --i) {
String word = words[i];
// seperate with dot
if (i != words.length - 1) {
sb.append('.");
}
sb.append(word);
}
String pkg = sb.toString();
if (pkg.equals("DefaultNamespace")) {
return "";
}
return pkg;
} catch (MalformedURLException e) {
}
return null;
|
public static java.lang.String | makeNamespace(java.lang.String clsName, java.lang.String protocol)Make namespace from a fully qualified class name
and the given protocol
if (clsName.startsWith("[L")) {
clsName = clsName.substring(2, clsName.length() - 1);
}
if (clsName.lastIndexOf('.") == -1) {
return protocol + "://" + "DefaultNamespace";
}
String packageName = clsName.substring(0, clsName.lastIndexOf('."));
return makeNamespaceFromPackageName(packageName, protocol);
|
public static java.lang.String | makeNamespace(java.lang.String clsName)Make namespace from a fully qualified class name
use the default protocol for the namespace
return makeNamespace(clsName, "http");
|
private static java.lang.String | makeNamespaceFromPackageName(java.lang.String packageName)Method makeNamespaceFromPackageName
return makeNamespaceFromPackageName(packageName, "http");
|
private static java.lang.String | makeNamespaceFromPackageName(java.lang.String packageName, java.lang.String protocol)Method makeNamespaceFromPackageName
if ((packageName == null) || packageName.equals("")) {
return protocol + "://" + "DefaultNamespace";
}
StringTokenizer st = new StringTokenizer(packageName, ".");
String[] words = new String[st.countTokens()];
for (int i = 0; i < words.length; ++i) {
words[i] = st.nextToken();
}
StringBuffer sb = new StringBuffer(80);
for (int i = words.length - 1; i >= 0; --i) {
String word = words[i];
// seperate with dot
if (i != words.length - 1) {
sb.append('.");
}
sb.append(word);
}
return protocol + "://" + sb.toString();
|
public java.lang.Object | put(java.lang.Object key, java.lang.Object value, java.lang.String prefix)adds an entry to the packagename/namespace HashMap. In addition,
also makes an entry in the auxillary namespace/prefix HashMap if an
entry doesn't already exists
if (prefix != null) {
namespacePrefixMap.put(value, prefix);
} else {
getCreatePrefix((String) value);
}
return super.put(key, value);
|
public void | putAll(java.util.Map map)adds an entry to the packagename/namespace HashMap
for each of the entry in the map. In addition, also add an entries in the
auxillary namespace/prefix HashMap
Iterator i = map.entrySet().iterator();
while (i.hasNext()) {
Map.Entry entry = (Map.Entry) i.next();
put(entry.getKey(), entry.getValue(), null);
}
|
public void | putAllPrefix(java.util.Map map)adds an entry to the namespace / prefix HashMap
for each of the entry in the map.
Iterator i = map.entrySet().iterator();
while (i.hasNext()) {
Map.Entry entry = (Map.Entry) i.next();
put(entry.getKey(), entry.getValue());
}
|
public void | putPrefix(java.lang.String namespace, java.lang.String prefix)put the gine namespace / prefix into the appropriate HashMap
namespacePrefixMap.put(namespace, prefix);
|