private synchronized NamespaceImpl create(String namespace) throws SQLException { if (byNamespace.containsKey(namespace)) return byNamespace.get(namespace); table.insert(null, namespace); NamespaceImpl ns = new NamespaceImpl(null, namespace); byNamespace.put(ns.getName(), ns); return ns; }
public void clearPrefixes() throws RdbmsException { try { table.clearPrefixes(); load(); } catch (SQLException e) { throw new RdbmsException(e); } }
public void setPrefix(String prefix, String name) throws RdbmsException { NamespaceImpl ns = findNamespace(name); try { table.updatePrefix(prefix, name); } catch (SQLException e) { throw new RdbmsException(e); } ns.setPrefix(prefix); byPrefix.put(prefix, ns); }
public void removePrefix(String prefix) throws RdbmsException { NamespaceImpl ns = findByPrefix(prefix); if (ns == null) return; try { table.updatePrefix(prefix, ns.getName()); } catch (SQLException e) { throw new RdbmsException(e); } ns.setPrefix(null); byPrefix.remove(prefix); }
private void load() throws SQLException { Map<String, NamespaceImpl> map = new HashMap<String, NamespaceImpl>(); Map<String, NamespaceImpl> prefixes = new HashMap<String, NamespaceImpl>(); for (Object[] row : table.selectAll()) { String prefix = (String) row[0]; String namespace = (String) row[1]; if (namespace == null) continue; NamespaceImpl ns = new NamespaceImpl(prefix, namespace); map.put(namespace, ns); if (prefix != null) { prefixes.put(prefix, ns); } } byNamespace.putAll(map); byPrefix.clear(); byPrefix.putAll(prefixes); }