Namespace is a Flyweight Namespace that can be shared amongst nodes.
Namespace
542543544545546547548549550551552
public boolean hasNext() { return iter.hasNext(); } public Object next() { Namespace ns = (Namespace) iter.next(); String prefix = ns.getPrefix(); String nsURI = ns.getURI(); return factory.createNamespace(prefix, nsURI); }
280281282283284285286287288289
* @param prefix DOCUMENT ME! * @param uri DOCUMENT ME! * @return DOCUMENT ME! */ public Namespace addNamespace(String prefix, String uri) { Namespace namespace = createNamespace(prefix, uri); push(namespace); return namespace; }
297298299300301302303304305306307308309310311312
public Namespace pop(String prefix) { if (prefix == null) { prefix = ""; } Namespace namespace = null; for (int i = namespaceStack.size() - 1; i >= 0; i--) { Namespace ns = (Namespace) namespaceStack.get(i); if (prefix.equals(ns.getPrefix())) { remove(i); namespace = ns; break; }
393394395396397398399400401402403404405406407408
* * @return DOCUMENT ME! */ protected Namespace findDefaultNamespace() { for (int i = namespaceStack.size() - 1; i >= 0; i--) { Namespace namespace = (Namespace) namespaceStack.get(i); if (namespace != null) { String prefix = namespace.getPrefix(); if ((prefix == null) || (namespace.getPrefix().length() == 0)) { return namespace; } } }
414415416417418419420421422423424
* * @param index DOCUMENT ME! * @return DOCUMENT ME! */ protected Namespace remove(int index) { Namespace namespace = (Namespace) namespaceStack.remove(index); namespaceCacheList.remove(index); defaultNamespace = null; currentNamespaceCache = null; return namespace;
5051525354555657585960616263
return null; } public String translateNamespacePrefixToUri(String prefix) { if ((prefix != null) && (prefix.length() > 0)) { Namespace ns = element.getNamespaceForPrefix(prefix); if (ns != null) { return ns.getURI(); } } return null; }
676869707172737475
// SerializationContext interface // ------------------------------------------------------------------------- public String getNamespacePrefix(String uri) { Namespace namespace = getNamespaceForURI(uri); return (namespace != null) ? namespace.getPrefix() : null; }
919293949596979899100101102103
// XXXX: no way to do this yet in dom4j so assume valid return true; } public String resolveNamespacePrefix(String prefix) { Namespace namespace = getNamespaceForPrefix(prefix); if (namespace != null) { return namespace.getURI(); } return null; }
8687888990919293949596979899
public String getNamespacePrefix(String uri) { Element parentElement = getParent(); if (parentElement != null) { Namespace namespace = parentElement.getNamespaceForURI(uri); if (namespace != null) { return namespace.getPrefix(); } } return null; }
122123124125126127128129130131132133134135136
return getNamespaceURI(); } else { Element parentElement = getParent(); if (parentElement != null) { Namespace namespace = parentElement .getNamespaceForPrefix(prefix); if (namespace != null) { return namespace.getURI(); } } } return null;