@Override public boolean containsValue(Object nextValue) { if (nextValue instanceof String) { for (Namespace nextNamespace : namespaces) { if (nextNamespace.getName().equals(nextValue)) { return true; } } } return false; }
@Override public int compareTo(Namespace other) { return uri.compareTo(other.getName()); }
@Override public int compareTo(Namespace other) { return uri.compareTo(other.getName()); }
@Override public Collection<String> values() { List<String> result = new ArrayList<String>(); for (Namespace nextNamespace : namespaces) { result.add(nextNamespace.getName()); } return result; } };
@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 String get(Object nextKey) { if (nextKey instanceof String) { for (Namespace nextNamespace : namespaces) { if (nextNamespace.getPrefix().equals(nextKey)) { return nextNamespace.getName(); } } } return null; }
@Override protected String getNamespaceInternal(String prefix) throws SailException { Namespace ns = namespaces.findByPrefix(prefix); if (ns == null) return null; return ns.getName(); }
/** * NOTE: This entry set is immutable, and does not update the internal * set through its iterator. */ @Override public Set<java.util.Map.Entry<String, String>> entrySet() { Set<java.util.Map.Entry<String, String>> result = new LinkedHashSet<Map.Entry<String, String>>(); for (Namespace nextNamespace : namespaces) { AbstractMap.SimpleImmutableEntry<String, String> nextEntry = new SimpleImmutableEntry<String, String>( nextNamespace.getPrefix(), nextNamespace.getName()); result.add(nextEntry); } return Collections.unmodifiableSet(result); }
@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; }
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; } }
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()); } }
/** * Sets the prefix for a namespace. * * @param namespace * a {@link Namespace} object to use in this Model. */ public final void setNamespace(final Namespace namespace) { doSetNamespace(namespace.getPrefix(), namespace.getName()); }
private void addContext() throws IOException { json.writeObjectFieldStart("@context"); List<Namespace> list = new ArrayList<>(nsManager.listNamespaces()); Collections.sort(list, new NamespaceComparator()); for (Namespace namespace : list) { json.writeStringField(namespace.getPrefix(), namespace.getName()); } json.writeEndObject(); } }
@Override public void setNamespace(Namespace namespace) { rc.setNamespace(namespace.getPrefix(), namespace.getName()); }
protected void initializeNamespaceTableFromConfiguration() { for (Namespace aNS : getParserConfig().get(BasicParserSettings.NAMESPACES)) { namespaceTable.put(aNS.getPrefix(), aNS.getName()); } }
private Namespaces getNamespaces(RepositoryConnection connection) throws RepositoryException { Namespaces ns = new Namespaces(); RepositoryResult<Namespace> rr = null; try { rr=connection.getNamespaces(); while(rr.hasNext()) { Namespace n=rr.next(); ns.addPrefix(n.getPrefix(), n.getName()); } } finally { closeQuietly(rr,"Could not close results after retrieving namespaces"); } return ns; }
private void declareNamespaces(NamespaceManager nsManager, Graph graph) { declareVann(graph); Collection<Namespace> list = nsManager.listNamespaces(); for (Namespace ns : list) { URI nsURI = uri(ns.getName()); Vertex v = graph.vertex(nsURI); if (v.getValue(VANN.preferredNamespacePrefix) == null) { v.addProperty(VANN.preferredNamespacePrefix, literal(ns.getPrefix())); } if (!v.hasProperty(RDF.TYPE, OWL.ONTOLOGY)) { v.addProperty(RDF.TYPE, OWL.ONTOLOGY); } } }