public String getPrefix(String namespaceUri) { List<String> prefixes = getPrefixesInternal(namespaceUri); return prefixes.isEmpty() ? null : prefixes.get(0); }
@Override public Iterator<String> getPrefixes(String namespaceUri) { Set<String> prefixes = getPrefixesInternal(namespaceUri); prefixes = Collections.unmodifiableSet(prefixes); return prefixes.iterator(); }
/** * Removes the given prefix from this context. * * @param prefix the prefix to be removed */ public void removeBinding(String prefix) { String namespaceUri = prefixToNamespaceUri.get(prefix); List<String> prefixes = getPrefixesInternal(namespaceUri); prefixes.remove(prefix); }
/** * Removes the given prefix from this context. * * @param prefix the prefix to be removed */ public void removeBinding(String prefix) { String namespaceUri = prefixToNamespaceUri.remove(prefix); if (namespaceUri != null) { Set<String> prefixes = getPrefixesInternal(namespaceUri); prefixes.remove(prefix); } }
/** * Removes the given prefix from this context. * * @param prefix the prefix to be removed */ public void removeBinding(String prefix) { String namespaceUri = prefixToNamespaceUri.remove(prefix); if (namespaceUri != null) { Set<String> prefixes = getPrefixesInternal(namespaceUri); prefixes.remove(prefix); } }
public Iterator<String> getPrefixes(String namespaceUri) { return getPrefixesInternal(namespaceUri).iterator(); }
@Override public Iterator<String> getPrefixes(String namespaceUri) { Set<String> prefixes = getPrefixesInternal(namespaceUri); prefixes = Collections.unmodifiableSet(prefixes); return prefixes.iterator(); }
/** * Binds the given prefix to the given namespace. * * @param prefix the namespace prefix * @param namespaceUri the namespace uri */ public void bindNamespaceUri(String prefix, String namespaceUri) { Assert.notNull(prefix, "No prefix given"); Assert.notNull(namespaceUri, "No namespaceUri given"); if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { Assert.isTrue(XMLConstants.XML_NS_URI.equals(namespaceUri), "Prefix \"" + prefix + "\" bound to namespace \"" + namespaceUri + "\" (should be \"" + XMLConstants.XML_NS_URI + "\")"); } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { Assert.isTrue(XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceUri), "Prefix \"" + prefix + "\" bound to namespace \"" + namespaceUri + "\" (should be \"" + XMLConstants.XMLNS_ATTRIBUTE_NS_URI + "\")"); } else { prefixToNamespaceUri.put(prefix, namespaceUri); getPrefixesInternal(namespaceUri).add(prefix); } }
/** * Binds the given prefix to the given namespace. * * @param prefix the namespace prefix * @param namespaceUri the namespace uri */ public void bindNamespaceUri(String prefix, String namespaceUri) { Assert.notNull(prefix, "No prefix given"); Assert.notNull(namespaceUri, "No namespaceUri given"); if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { Assert.isTrue(XMLConstants.XML_NS_URI.equals(namespaceUri), "Prefix \"" + prefix + "\" bound to namespace \"" + namespaceUri + "\" (should be \"" + XMLConstants.XML_NS_URI + "\")"); } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { Assert.isTrue(XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceUri), "Prefix \"" + prefix + "\" bound to namespace \"" + namespaceUri + "\" (should be \"" + XMLConstants.XMLNS_ATTRIBUTE_NS_URI + "\")"); } else { prefixToNamespaceUri.put(prefix, namespaceUri); getPrefixesInternal(namespaceUri).add(prefix); } }
/** * Binds the given prefix to the given namespace. * * @param prefix the namespace prefix * @param namespaceUri the namespace uri */ public void bindNamespaceUri(String prefix, String namespaceUri) { Assert.notNull(prefix, "No prefix given"); Assert.notNull(namespaceUri, "No namespaceUri given"); if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { Assert.isTrue(XMLConstants.XML_NS_URI.equals(namespaceUri), "Prefix \"" + prefix + "\" bound to namespace \"" + namespaceUri + "\" (should be \"" + XMLConstants.XML_NS_URI + "\")"); } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { Assert.isTrue(XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceUri), "Prefix \"" + prefix + "\" bound to namespace \"" + namespaceUri + "\" (should be \"" + XMLConstants.XMLNS_ATTRIBUTE_NS_URI + "\")"); } else { prefixToNamespaceUri.put(prefix, namespaceUri); getPrefixesInternal(namespaceUri).add(prefix); } }