Search in sources :

Example 56 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class TestNode method testCreatePrefixed.

public void testCreatePrefixed() {
    PrefixMapping pm = PrefixMapping.Factory.create();
    /* TODO Node n = */
    NodeCreateUtils.create(pm, "xyz");
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 57 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class TestNode method testCreateURIOtherMap.

public void testCreateURIOtherMap() {
    String myNS = "eh:foo/bar#", suffix = "something";
    PrefixMapping mine = PrefixMapping.Factory.create().setNsPrefix("mine", myNS);
    Node n = NodeCreateUtils.create(mine, "mine:" + suffix);
    assertEquals(myNS + suffix, n.getURI());
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 58 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class TestNode method testToStringWithPrefixMapping.

public void testToStringWithPrefixMapping() {
    PrefixMapping pm = PrefixMapping.Factory.create();
    String prefix = "spoo", ns = "abc:def/ghi#";
    pm.setNsPrefix(prefix, ns);
    String suffix = "bamboozle";
    assertEquals(prefix + ":" + suffix, NodeCreateUtils.create(ns + suffix).toString(pm));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 59 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class TestTriple method testTripleToStringWithPrefixing.

public void testTripleToStringWithPrefixing() {
    PrefixMapping pm = PrefixMapping.Factory.create();
    pm.setNsPrefix("spoo", "eg://domain.dom/spoo#");
    Triple t1 = NodeCreateUtils.createTriple("eg://domain.dom/spoo#a b c");
    assertEquals("spoo:a @eh:/b eh:/c", t1.toString(pm));
}
Also used : Triple(org.apache.jena.graph.Triple) PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 60 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class WhereClauseTest method testAddOptionalTriplePath.

@ContractTest
public void testAddOptionalTriplePath() {
    WhereClause<?> whereClause = getProducer().newInstance();
    PrefixMapping pmap = new PrefixMappingImpl();
    pmap.setNsPrefix("ts", "urn:test:");
    Path path = PathParser.parse("ts:two/ts:dos", pmap);
    AbstractQueryBuilder<?> builder = whereClause.addOptional(new TriplePath(NodeFactory.createURI("one"), path, NodeFactory.createURI("three")));
    ElementPathBlock epb = new ElementPathBlock();
    ElementOptional optional = new ElementOptional(epb);
    TriplePath tp = new TriplePath(NodeFactory.createURI("one"), path, NodeFactory.createURI("three"));
    epb.addTriplePath(tp);
    WhereValidator visitor = new WhereValidator(optional);
    builder.build().getQueryPattern().visit(visitor);
    assertTrue(visitor.matching);
}
Also used : TriplePath(org.apache.jena.sparql.core.TriplePath) Path(org.apache.jena.sparql.path.Path) PrefixMapping(org.apache.jena.shared.PrefixMapping) ElementOptional(org.apache.jena.sparql.syntax.ElementOptional) WhereValidator(org.apache.jena.arq.querybuilder.WhereValidator) TriplePath(org.apache.jena.sparql.core.TriplePath) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) ElementPathBlock(org.apache.jena.sparql.syntax.ElementPathBlock) ContractTest(org.xenei.junit.contract.ContractTest)

Aggregations

PrefixMapping (org.apache.jena.shared.PrefixMapping)149 Test (org.junit.Test)47 PrefixMappingImpl (org.apache.jena.shared.impl.PrefixMappingImpl)29 Graph (org.apache.jena.graph.Graph)22 BaseTest (org.apache.jena.atlas.junit.BaseTest)11 Triple (org.apache.jena.graph.Triple)9 Resource (org.apache.jena.rdf.model.Resource)9 Path (org.apache.jena.sparql.path.Path)8 ConfigTest (org.apache.jena.tdb.ConfigTest)8 DatasetPrefixesTDB (org.apache.jena.tdb.store.DatasetPrefixesTDB)8 ContractTest (org.xenei.junit.contract.ContractTest)8 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)7 ArrayList (java.util.ArrayList)5 Node (org.apache.jena.graph.Node)5 Query (org.apache.jena.query.Query)5 Model (org.apache.jena.rdf.model.Model)5 PrefixMappingSDB (org.apache.jena.sdb.graph.PrefixMappingSDB)5 URI (java.net.URI)4 HashMap (java.util.HashMap)4 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)4