@Override public Set<Namespace> getNamespaces() { return model.getNamespaces(); }
public Map<String, String> getNamespaces() { return model.getNamespaces(); }
public Map<String, String> getNamespaces() { return models[0].getNamespaces(); }
@Override public Set<Namespace> getNamespaces() { return this.model.getNamespaces(); }
@Override public Set<Namespace> getNamespaces() { return Collections.unmodifiableSet(model.getNamespaces()); }
/** * 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(); }
public TreeModel(Model model) { this(model.getNamespaces()); addAll(model); }
public LinkedHashModel(Model model) { this(model.getNamespaces()); addAll(model); }
public MemoryOverflowModel(Model model) { this(model.getNamespaces()); addAll(model); }
public LinkedHashModel(Model model) { this(model.getNamespaces()); addAll(model); }
public TreeModel(Model model) { this(model.getNamespaces()); addAll(model); }
/** * Creates a new StatementCollector that stores reported statements in the * supplied collection and that uses a new LinkedHashMap to store the * reported namespaces. */ public ContextStatementCollector(Collection<Statement> statements, ValueFactory vf, Resource... contexts) { OpenRDFUtil.verifyContextNotNull(contexts); if (statements instanceof Model) { this.namespaces = Namespaces.wrap(((Model)statements).getNamespaces()); } else { this.namespaces = new LinkedHashMap<String, String>(); } this.statements = statements; this.vf = vf; this.contexts = contexts; }
private String findPrefix(String ns, Model model) { for (Map.Entry<String, String> e : model.getNamespaces().entrySet()) { if (ns.equals(e.getValue()) && e.getKey().length() > 0) { return e.getKey(); } } if (resolvingPrefix) { String prefix = NamespacePrefixService.getInstance().prefix(ns); if (prefix != null && model.getNamespace(prefix) == null) { model.setNamespace(prefix, ns); return prefix; } } return "ns" + Integer.toHexString(ns.hashCode()); }
/** * Test method for {@link org.openrdf.model.Model#getNamespaces()}. */ @Test public final void testGetNamespacesEmpty() { Set<Namespace> namespaces = testModel.getNamespaces(); assertNotNull("Namespaces set must not be null", namespaces); assertTrue("Namespaces must initially be empty", namespaces.isEmpty()); }
private String findPrefix(String ns, Model model) { for (Namespace e : model.getNamespaces()) { if (ns.equals(e.getName()) && e.getPrefix().length() > 0) { return e.getPrefix(); } } if (resolvingPrefix) { String prefix = NamespacePrefixService.getInstance().prefix(ns); if (prefix != null && model.getNamespace(prefix) == null) { model.setNamespace(prefix, ns); return prefix; } } return "ns" + Integer.toHexString(ns.hashCode()); }
/** * Test method for {@link org.openrdf.model.Model#getNamespaces()}. */ @Test public final void testGetNamespacesSingle() { testModel.setNamespace(RDF.PREFIX, RDF.NAMESPACE); Set<Namespace> namespaces = testModel.getNamespaces(); assertNotNull("Namespaces set must not be null", namespaces); assertFalse(namespaces.isEmpty()); assertEquals(1, namespaces.size()); assertTrue("Did not find the expected namespace in the set", namespaces.contains(new SimpleNamespace(RDF.PREFIX, RDF.NAMESPACE))); }
/** * Test method for * {@link org.openrdf.model.Model#removeNamespace(java.lang.String)}. */ @Test public final void testRemoveNamespaceEmpty() { Set<Namespace> namespaces = testModel.getNamespaces(); assertNotNull("Namespaces set must not be null", namespaces); assertTrue("Namespaces must initially be empty", namespaces.isEmpty()); assertFalse(testModel.removeNamespace(RDF.NAMESPACE).isPresent()); assertFalse(testModel.removeNamespace(RDFS.NAMESPACE).isPresent()); assertFalse(testModel.removeNamespace(DC.NAMESPACE).isPresent()); assertFalse(testModel.removeNamespace(SKOS.NAMESPACE).isPresent()); assertFalse(testModel.removeNamespace(SESAME.NAMESPACE).isPresent()); }
/** * Test method for * {@link org.openrdf.model.Model#setNamespace(java.lang.String, java.lang.String)}. */ @Test public final void testSetNamespaceSamePrefix() { testModel.setNamespace("r", RDF.NAMESPACE); testModel.setNamespace("r", RDFS.NAMESPACE); Set<Namespace> namespaces = testModel.getNamespaces(); assertNotNull("Namespaces set must not be null", namespaces); assertEquals(1, namespaces.size()); assertEquals(new SimpleNamespace("r", RDFS.NAMESPACE), testModel.getNamespace("r").orElse(null)); }
/** * Test method for * {@link org.openrdf.model.Model#setNamespace(org.openrdf.model.Namespace)}. */ @Test public final void testSetNamespaceNamespaceSamePrefix() { testModel.setNamespace(new SimpleNamespace("r", RDF.NAMESPACE)); testModel.setNamespace(new SimpleNamespace("r", RDFS.NAMESPACE)); Set<Namespace> namespaces = testModel.getNamespaces(); assertNotNull("Namespaces set must not be null", namespaces); assertEquals(1, namespaces.size()); assertEquals(new SimpleNamespace("r", RDFS.NAMESPACE), testModel.getNamespace("r").orElse(null)); }
public Model filter(Model model, BindingSet bindings) { Resource subj = (Resource) value(sp.getSubjectVar(), bindings); URI pred = (URI) value(sp.getPredicateVar(), bindings); Value obj = value(sp.getObjectVar(), bindings); Resource[] contexts = contexts(sp, dataset, bindings); if (contexts == null) return new LinkedHashModel(model.getNamespaces()); return model.filter(subj, pred, obj, contexts); }