@Override public Namespace next() throws SailException { _current = prefix2ns.next(); return _current == null ? null : new NamespaceImpl(_current.getKey(), _current.getValue()); }
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 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); }
@Override public Namespace next() throws SailException { _current = prefix2ns.next(); return _current == null ? null : new NamespaceImpl(_current.getKey(), _current.getValue()); }
@Override protected Namespace doSetNamespace(final String prefix, @Nullable final String name) { if (name == null) { return this.namespaces.remove(prefix); } else { return this.namespaces.put(prefix, new NamespaceImpl(prefix, name)); } }
public Namespace next() { final Map.Entry<String/*prefix*/,String/*namespace*/> current = src.next(); return new NamespaceImpl(current.getKey(), current.getValue()); }
public Namespace next() { final Map.Entry<String/*prefix*/,String/*namespace*/> current = src.next(); return new NamespaceImpl(current.getKey(), current.getValue()); }
public Namespace next() throws SailException { if (addedIter != null && addedIter.hasNext()) { Entry<String, String> e = addedIter.next(); return new NamespaceImpl(e.getKey(), e.getValue()); } try { if (hasNext()) return next; throw new NoSuchElementException(); } finally { next = null; } }
/** * Sets the prefix for a namespace. * * @param prefix * the prefix * @param name * the namespace that the prefix maps to * @return the {@link Namespace} object for the given namespace */ public final Namespace setNamespace(final String prefix, final String name) { doSetNamespace(Objects.requireNonNull(prefix), Objects.requireNonNull(name)); return new NamespaceImpl(prefix, name); }
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); }
public static Namespace getNamespace(final Iterator<Entry<Key, Value>> rowResults) { for (; rowResults.hasNext(); ) { final Entry<Key, Value> next = rowResults.next(); final Key key = next.getKey(); final Value val = next.getValue(); final String cf = key.getColumnFamily().toString(); final String cq = key.getColumnQualifier().toString(); return new NamespaceImpl(key.getRow().toString(), new String(val.get(), StandardCharsets.UTF_8)); } return null; }
@Override @Nullable protected Namespace doGetNamespace(final String prefix) { try { final String name = this.connection.getNamespace(prefix); return name == null ? null : new NamespaceImpl(prefix, name); } catch (final RepositoryException ex) { throw new ModelException(ex); } }
@Override @Nullable protected Namespace doGetNamespace(final String prefix) { try { final String name = this.connection.getNamespace(prefix); return name == null ? null : new NamespaceImpl(prefix, name); } catch (final SailException ex) { throw new ModelException(ex); } }
/** * Handles a namespace declaration/definition. */ public void handleNamespace(final String prefix, final String uri) { try { nsSink.accept(new NamespaceImpl(prefix, uri)); } catch (Exception e) { // Log the error, but continue. logError(e); } }
@Override public RepositoryResult<Namespace> getNamespaces() throws RepositoryException { //Gets all declared namespaces as a RepositoryResult of Namespace objects. //Each Namespace object consists of a prefix and a namespace name. Set<Namespace> namespSet = new HashSet<Namespace>(); Map<String, String> namesp = repository.getNamespaces(); Set<String> keys = namesp.keySet(); for (String key : keys) { //convert into namespace objects namespSet.add(new NamespaceImpl(key, namesp.get(key))); } return new RepositoryResult<Namespace>(new CloseableIteratorIteration<Namespace, RepositoryException>( namespSet.iterator())); }
@Override public String javaClassName(URI owlClass) { String namespaceName = owlClass.getNamespace(); Namespace ns = nsManager.findByName(namespaceName); if (ns == null) { if (namespaceName.equals(OWL.NAMESPACE)) { ns = new NamespaceImpl("owl", namespaceName); } else { logger.warn("Prefix for namespace not found: " + owlClass.getNamespace()); } } String prefix = ns==null ? defaultPrefix : ns.getPrefix(); StringBuilder builder = new StringBuilder(basePackage); builder.append("impl."); builder.append(prefix); builder.append('.'); builder.append(owlClass.getLocalName()); builder.append("Impl"); return builder.toString(); }
@Override public String javaInterfaceName(URI owlClass) { String namespaceName = owlClass.getNamespace(); Namespace ns = nsManager.findByName(namespaceName); if (ns == null) { if (namespaceName.equals(OWL.NAMESPACE)) { ns = new NamespaceImpl("owl", namespaceName); } else { logger.warn("Prefix for namespace not found: " + owlClass.getNamespace()); } } String prefix = ns==null ? defaultPrefix : ns.getPrefix(); StringBuilder builder = new StringBuilder(basePackage); builder.append("model."); builder.append(prefix); builder.append('.'); builder.append(owlClass.getLocalName()); return builder.toString(); }
@Override protected Namespace doSetNamespace(final String prefix, @Nullable final String name) { try { final String oldName = this.connection.getNamespace(prefix); final Namespace oldNamespace = oldName == null ? null : new NamespaceImpl(prefix, oldName); if (name == null) { this.connection.removeNamespace(prefix); } else { this.connection.setNamespace(prefix, name); } return oldNamespace; } catch (final RepositoryException ex) { throw new ModelException(ex); } }