/** * @param nextNamespaces set of namespaces to set */ public void setNamespaces(Set<Namespace> nextNamespaces) { namespaces.clear(); namespaces.putAll(Namespaces.asMap(nextNamespaces)); }
/** * 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 NamespaceAware) { this.namespaces = Namespaces.wrap(((NamespaceAware)statements).getNamespaces()); } else { this.namespaces = new LinkedHashMap<>(); } this.statements = statements; this.vf = vf; this.contexts = contexts; }
/** * 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 NamespaceAware) { this.namespaces = Namespaces.wrap(((NamespaceAware)statements).getNamespaces()); } else { this.namespaces = new LinkedHashMap<String, String>(); } this.statements = statements; this.vf = vf; this.contexts = contexts; }
/** * @param nextNamespaces set of namespaces to set */ public void setNamespaces(Set<Namespace> nextNamespaces) { namespaces.clear(); namespaces.putAll(Namespaces.asMap(nextNamespaces)); }
/** * 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 NamespaceAware) { this.namespaces = Namespaces.wrap(((NamespaceAware)statements).getNamespaces()); } else { this.namespaces = new LinkedHashMap<String, String>(); } this.statements = statements; this.vf = vf; this.contexts = contexts; }
/** * Creates a RioMemoryTripleSource using an {@link Iterable} of * {@link Statement} objects. <br> * If the Iterable is an instance of {@link Model}, the namespaces from the * model are also used. * * @param statements A {@link CloseableIteration} of {@link Statement} objects that make up this * source. */ public RioMemoryTripleSource(Iterable<Statement> statements) { documentIRI = IRI.getNextDocumentIRI("rio-memory-triples:"); statementIterator = statements.iterator(); if (statements instanceof Model) { namespaces.putAll(Namespaces.asMap(((Model) statements).getNamespaces())); } }
/** * Creates a RioMemoryTripleSource using an {@link Iterable} of * {@link Statement} objects. <br> * If the Iterable is an instance of {@link Model}, the namespaces from the * model are also used. * * @param statements A {@link CloseableIteration} of {@link Statement} objects that make up this * source. */ public RioMemoryTripleSource(Iterable<Statement> statements) { documentIRI = IRI.getNextDocumentIRI("rio-memory-triples:"); statementIterator = statements.iterator(); if (statements instanceof Model) { namespaces.putAll(Namespaces.asMap(((Model) statements).getNamespaces())); } }
@Override public void testGetNamespaces() throws Exception { setupNamespaces(); Map<String, String> map = Namespaces.asMap(Iterations.asSet(testCon.getNamespaces())); assertThat(map.size(), is(equalTo(3))); assertThat(map.keySet(), hasItems("example", "rdfs", "rdf")); assertThat(map.get("example"), is(equalTo("http://example.org/"))); assertThat(map.get("rdfs"), is(equalTo("http://www.w3.org/2000/01/rdf-schema#"))); assertThat(map.get("rdf"), is(equalTo("http://www.w3.org/1999/02/22-rdf-syntax-ns#"))); }