Search in sources :

Example 11 with PrefixMappingImpl

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;
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl)

Example 12 with PrefixMappingImpl

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"));
}
Also used : PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) Test(org.junit.Test)

Example 13 with PrefixMappingImpl

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);
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Graph(org.apache.jena.graph.Graph) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) Test(org.junit.Test)

Example 14 with PrefixMappingImpl

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));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Graph(org.apache.jena.graph.Graph) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) Test(org.junit.Test)

Example 15 with PrefixMappingImpl

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));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Graph(org.apache.jena.graph.Graph) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) Test(org.junit.Test)

Aggregations

PrefixMappingImpl (org.apache.jena.shared.impl.PrefixMappingImpl)39 PrefixMapping (org.apache.jena.shared.PrefixMapping)34 Test (org.junit.Test)13 Path (org.apache.jena.sparql.path.Path)11 Graph (org.apache.jena.graph.Graph)8 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)4 TriplePath (org.apache.jena.sparql.core.TriplePath)4 ElementPathBlock (org.apache.jena.sparql.syntax.ElementPathBlock)4 BeforeClass (org.junit.BeforeClass)4 ElementOptional (org.apache.jena.sparql.syntax.ElementOptional)3 ContractTest (org.xenei.junit.contract.ContractTest)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Triple (org.apache.jena.graph.Triple)2 Dataset (org.apache.jena.query.Dataset)2 Date (java.util.Date)1 Trie (org.apache.jena.atlas.lib.Trie)1 SecuredPrefixMapping (org.apache.jena.permissions.graph.SecuredPrefixMapping)1 Query (org.apache.jena.query.Query)1 UpdateDeniedException (org.apache.jena.shared.UpdateDeniedException)1