@Override public boolean containsKey(Object nextKey) { if (nextKey instanceof String) { for (Namespace nextNamespace : namespaces) { if (nextNamespace.getPrefix().equals(nextKey)) { return true; } } } return false; }
@Override public Set<String> keySet() { Set<String> result = new LinkedHashSet<String>(); for (Namespace nextNamespace : namespaces) { result.add(nextNamespace.getPrefix()); } return result; }
@Override public Optional<Namespace> getNamespace(String prefix) { for (Namespace nextNamespace : namespaces) { if (prefix.equals(nextNamespace.getPrefix())) { return Optional.of(nextNamespace); } } return Optional.empty(); }
@Override public Optional<Namespace> getNamespace(String prefix) { for (Namespace nextNamespace : namespaces) { if (prefix.equals(nextNamespace.getPrefix())) { return Optional.of(nextNamespace); } } return Optional.empty(); }
@Override public void setNamespace(Namespace namespace) { removeNamespace(namespace.getPrefix()); namespaces.add(namespace); }
@Override public String remove(Object nextKey) { String result = null; for (Namespace nextNamespace : new LinkedHashSet<Namespace>(namespaces)) { if (nextNamespace.getPrefix().equals(nextKey)) { result = nextNamespace.getName(); namespaces.remove(nextNamespace); } } return result; }
private static void addPrefixes(Map<String, Object> ctx, Set<Namespace> namespaces) { for (final Namespace ns : namespaces) { ctx.put(ns.getPrefix(), ns.getName()); } } }
@Override public void setNamespace(Namespace namespace) { removeNamespace(namespace.getPrefix()); namespaces.add(namespace); }
@Override public String get(Object nextKey) { if (nextKey instanceof String) { for (Namespace nextNamespace : namespaces) { if (nextNamespace.getPrefix().equals(nextKey)) { return nextNamespace.getName(); } } } return null; }
/** * Gets the namespace that is associated with the specified prefix, if any. * * @param prefix * A namespace prefix. * @return The namespace name that is associated with the specified prefix, * or {@link Optional#empty()} if there is no such namespace. */ public default Optional<Namespace> getNamespace(String prefix) { return getNamespaces().stream().filter(t -> t.getPrefix().equals(prefix)).findAny(); }
@Override public String put(String nextKey, String nextValue) { String result = null; for (Namespace nextNamespace : new LinkedHashSet<Namespace>(namespaces)) { if (nextNamespace.getPrefix().equals(nextKey)) { result = nextNamespace.getName(); namespaces.remove(nextNamespace); } } namespaces.add(new SimpleNamespace(nextKey, nextValue)); return result; }
@Override public String jsonSchemaFileName(Shape shape) { URI shapeId = (URI) shape.getId(); StringBuilder builder = new StringBuilder(); builder.append(namespace(shapeId).getPrefix()); builder.append('.'); builder.append(shapeId.getLocalName()); builder.append(".json"); return builder.toString(); }
public Map<String, String> asMap() throws StoreException { Map<String, String> map = new HashMap<String, String>(); Namespace ns; while ((ns = next()) != null) { map.put(ns.getPrefix(), ns.getName()); } return map; } }
public boolean hasNext() throws SailException { if (addedIter != null && addedIter.hasNext()) return true; while (next == null && namespaces.hasNext()) { next = namespaces.next(); if (removedSet != null && removedSet.contains(next.getPrefix())) { next = null; } } return next != null; }
@Override public File getFile(URI ontologyId) { Namespace namespace = nsManager.findByName(ontologyId.stringValue()); if (namespace == null) { throw new KonigException("Prefix not found for namespace: " + ontologyId.stringValue()); } String prefix = namespace.getPrefix(); StringBuilder builder = new StringBuilder(); builder.append(prefix); builder.append(".ttl"); return new File(baseDir, builder.toString()); }
private void writeNamespaces(NamespaceManager nsManager, RDFWriter turtle) throws RDFHandlerException { List<Namespace> list = new ArrayList<>(nsManager.listNamespaces()); Collections.sort(list, new Comparator<Namespace>(){ @Override public int compare(Namespace a, Namespace b) { return a.getPrefix().compareTo(b.getPrefix()); }}); for (Namespace ns : list) { turtle.handleNamespace(ns.getPrefix(), ns.getName()); } }
protected void initializeNamespaceTableFromConfiguration() { for (Namespace aNS : getParserConfig().get(BasicParserSettings.NAMESPACES)) { namespaceTable.put(aNS.getPrefix(), aNS.getName()); } }
@Override protected void clearNamespacesInternal() throws SailException { for(Namespace ns : Iterations.asList(getNamespacesInternal())) { removeNamespaceInternal(ns.getPrefix()); } }