use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class BuilderPrefixMapping method build.
public static PrefixMapping build(Item elt) {
PrefixMapping pmap = new PrefixMappingImpl();
build(pmap, elt);
return pmap;
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class TestParameterizedSparqlString method test_param_string_constructor_9.
@Test
public void test_param_string_constructor_9() {
// Test constructors with predefined prefixes - variant of constructor
// that does not require command text
PrefixMappingImpl prefixes = new PrefixMappingImpl();
prefixes.setNsPrefix("ex", "http://example.org");
ParameterizedSparqlString query = new ParameterizedSparqlString(prefixes);
Assert.assertEquals(prefixes.getNsPrefixURI("ex"), query.getNsPrefixURI("ex"));
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class TestPrefixMappingUtils method prefixesN.
@Test
public void prefixesN() {
// All combinations.
// No "@prefix xsd: <"+XSD.getURI()+"> ." so not in output.
String data = StrUtils.strjoinNL("@prefix : <http://example/> .", "@prefix ex: <http://example/ex#> .", "@prefix notinuse: <http://example/whatever/> .", "@prefix indirect: <urn:foo:> .", "@prefix indirectx: <urn:ex:> .", "@prefix ns: <http://host/ns> .", "@prefix ns1: <http://host/ns1> .", "@prefix ns2: <http://host/nspace> .", "", ":s1 :p :x1 .", ":s1 ex:p :x1 .", "<urn:foo:bar> :p 1 . ", "<urn:ex:a:b> :p 2 . ", "<urn:ex:verybad#.> :p 1 . ", "ns:x ns1:p 'ns1' . ", "<http://examp/abberev> indirect:p 'foo' . ");
Graph graph = create(data);
PrefixMapping pmap = PrefixMappingUtils.calcInUsePrefixMapping(graph);
PrefixMapping pmapExpected = new PrefixMappingImpl();
pmapExpected.setNsPrefix("", "http://example/");
pmapExpected.setNsPrefix("ex", "http://example/ex#");
pmapExpected.setNsPrefix("indirect", "urn:foo:");
pmapExpected.setNsPrefix("ns", "http://host/ns");
pmapExpected.setNsPrefix("ns1", "http://host/ns1");
pmapExpected.setNsPrefix("indirectx", "urn:ex:");
// print("Expected:", pmapExpected) ;
// print("Got:", pmap) ;
Assert.assertTrue(sameMapping(pmapExpected, pmap));
Assert.assertTrue(pmap.getNsPrefixURI("notinuse") == null);
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class TestPrefixMappingUtils method prefixes4.
@Test
public void prefixes4() {
// No prefixes.
String data = StrUtils.strjoinNL("<http://other/s1> <http://example/p> 123 .");
Graph graph1 = create(data);
PrefixMapping pmap = PrefixMappingUtils.calcInUsePrefixMapping(graph1);
Assert.assertEquals(0, size(pmap));
PrefixMapping pmapExpected = new PrefixMappingImpl();
Assert.assertTrue(sameMapping(pmapExpected, pmap));
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class TestPrefixMappingUtils method prefixes3.
@Test
public void prefixes3() {
// Some URIs without prefixes.
String data = StrUtils.strjoinNL("@prefix : <http://example/> .", "", "<http://other/s1> :p :x1 .");
Graph graph1 = create(data);
PrefixMapping pmap = PrefixMappingUtils.calcInUsePrefixMapping(graph1);
PrefixMapping pmapExpected = new PrefixMappingImpl();
pmapExpected.setNsPrefix("", "http://example/");
Assert.assertTrue(sameMapping(pmapExpected, pmap));
}
Aggregations