@Override public String getNamespaceForPrefix(String prefix) { Lock lock = this.namespacesLock.readLock(); try { lock.lock(); CheckArg.isNotNull(prefix, "prefix"); return cache.getNamespaceForPrefix(prefix); } finally { lock.unlock(); } }
@Override public Set<Namespace> getNamespaces() { final Lock lock = this.namespacesLock.readLock(); try { lock.lock(); // Just return what's in the cache ... return cache.getNamespaces(); } finally { lock.unlock(); } }
@Override public boolean isRegisteredNamespaceUri(String namespaceUri) { CheckArg.isNotNull(namespaceUri, "namespaceUri"); Lock lock = this.namespacesLock.readLock(); try { lock.lock(); return cache.isRegisteredNamespaceUri(namespaceUri); } finally { lock.unlock(); } }
@Override public Set<String> getRegisteredNamespaceUris() { final Lock lock = this.namespacesLock.readLock(); try { lock.lock(); // Just return what's in the cache ... return cache.getRegisteredNamespaceUris(); } finally { lock.unlock(); } }
@Override public String getPrefixForNamespaceUri(String namespaceUri, boolean generateIfMissing) { CheckArg.isNotNull(namespaceUri, "namespaceUri"); Lock lock = this.namespacesLock.readLock(); try { lock.lock(); // Try the cache first ... String prefix = cache.getPrefixForNamespaceUri(namespaceUri, false); if (prefix == null && generateIfMissing) { SystemContent systemContent = systemContent(!generateIfMissing); prefix = systemContent.readNamespacePrefix(namespaceUri, generateIfMissing); if (prefix != null) { systemContent.save(); cache.register(prefix, namespaceUri); } } return prefix; } finally { lock.unlock(); } }