Search in sources :

Example 16 with PrefixMap

use of org.apache.jena.riot.system.PrefixMap in project jena by apache.

the class SHACLC method withStandardPrefixes.

/**
 * Return a copy of the {@link PrefixMap} with the SHACLC standard prefixes added
 */
public static PrefixMap withStandardPrefixes(PrefixMap pmap) {
    PrefixMap pmap2 = PrefixMapFactory.create();
    addStandardPrefixes(pmap2);
    // Add second to override any of the standard settings.
    pmap2.putAll(pmap);
    return pmap2;
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap)

Example 17 with PrefixMap

use of org.apache.jena.riot.system.PrefixMap in project jena by apache.

the class TestDatasetPrefixes method dsg_prefixes_basic_4.

@Test
public void dsg_prefixes_basic_4() {
    DatasetGraph dsg = create();
    Txn.executeWrite(dsg, () -> {
        PrefixMap pmap = dsg.prefixes();
        pmap.add("ex", "http://example/");
        pmap.delete("ex");
        String x = pmap.get("ex");
        assertNull(x);
        assertEquals(0, pmap.size());
        assertTrue(pmap.isEmpty());
    });
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 18 with PrefixMap

use of org.apache.jena.riot.system.PrefixMap in project jena by apache.

the class TestDatasetPrefixes method dsg_prefixes_basic_3.

@Test
public void dsg_prefixes_basic_3() {
    DatasetGraph dsg = create();
    Txn.executeWrite(dsg, () -> {
        PrefixMap pmap = dsg.prefixes();
        pmap.add("ex", "http://example/");
        pmap.add("ex", "http://example/1");
        String x = pmap.get("ex");
        assertEquals("http://example/1", x);
        assertEquals(1, pmap.size());
        assertFalse(pmap.isEmpty());
    });
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 19 with PrefixMap

use of org.apache.jena.riot.system.PrefixMap in project jena by apache.

the class TestDatasetPrefixes method dsg_prefixes_basic_5.

@Test
public void dsg_prefixes_basic_5() {
    Assume.assumeTrue(unifiedPrefixMaps);
    DatasetGraph dsg = create();
    Txn.executeWrite(dsg, () -> {
        PrefixMap pmap = dsg.prefixes();
        pmap.add("ex", "http://example/");
        PrefixMap pmapDft = Prefixes.adapt(dsg.getDefaultGraph().getPrefixMapping());
        String x1 = pmapDft.get("ex");
        assertEquals("http://example/", x1);
        pmapDft.add("ex", "http://example/ns2");
        PrefixMap pmapUnion = Prefixes.adapt(dsg.getUnionGraph().getPrefixMapping());
        String x2 = pmapUnion.get("ex");
        assertEquals("http://example/ns2", x2);
        String x3 = pmap.get("ex");
        assertEquals("http://example/ns2", x2);
    });
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 20 with PrefixMap

use of org.apache.jena.riot.system.PrefixMap in project jena by apache.

the class ShaclCompactParser method iriOrLiteral.

// iriOrLiteral: If there is an iri, return the node derived from iri. Otherwise,
// apply Turtle's parsing rules to turn the string literal into an RDF literal.
// (from the test cases, this does not mean parse the node string again)
private Node iriOrLiteral(Node x) {
    if (x.isURI())
        return x;
    String s = x.getLiteralLexicalForm();
    PrefixMap pmap = super.profile.getPrefixMap();
    Node n = TokenizerText.create().fromString(s).build().next().asNode(pmap);
    return n;
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap) Node(org.apache.jena.graph.Node)

Aggregations

PrefixMap (org.apache.jena.riot.system.PrefixMap)33 Test (org.junit.Test)16 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)10 Map (java.util.Map)3 Node (org.apache.jena.graph.Node)2 QueryCancelledException (org.apache.jena.query.QueryCancelledException)2 QueryExecException (org.apache.jena.query.QueryExecException)2 NodeFormatter (org.apache.jena.riot.out.NodeFormatter)2 NodeFormatterTTL (org.apache.jena.riot.out.NodeFormatterTTL)2 JsonLdApi (com.github.jsonldjava.core.JsonLdApi)1 JsonLdOptions (com.github.jsonldjava.core.JsonLdOptions)1 RDFDataset (com.github.jsonldjava.core.RDFDataset)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 Iter (org.apache.jena.atlas.iterator.Iter)1 JsonObject (org.apache.jena.atlas.json.JsonObject)1 JsonString (org.apache.jena.atlas.json.JsonString)1 StoragePrefixes (org.apache.jena.dboe.storage.StoragePrefixes)1