예제 #1
0
 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;
 }
예제 #2
0
 public void clearPrefixes() throws RdbmsException {
   try {
     table.clearPrefixes();
     load();
   } catch (SQLException e) {
     throw new RdbmsException(e);
   }
 }
예제 #3
0
 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);
 }
예제 #4
0
 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);
 }
예제 #5
0
 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);
 }