use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class PrologClauseTest method testAddPrefixes_PrefixMapping.
@ContractTest
public void testAddPrefixes_PrefixMapping() {
PrefixMapping map = new PrefixMappingImpl();
map.setNsPrefix("pfx", "uri");
map.setNsPrefix("pfx2", "uri2");
PrologClause<?> prologClause = getProducer().newInstance();
AbstractQueryBuilder<?> builder = prologClause.addPrefixes(map);
Query q = builder.build();
PrefixMapping map2 = q.getPrefixMapping();
assertEquals(map.getNsPrefixURI("pfx"), map2.getNsPrefixURI("pfx"));
assertEquals(map.getNsPrefixURI("pfx2"), map2.getNsPrefixURI("pfx2"));
assertEquals(2, map2.getNsPrefixMap().size());
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class ParseHandlerResolver method declItem.
@Override
protected void declItem(ItemList list, Item item) {
if (list != declList)
// Deeper
return;
// Prefix - deeper than one.
boolean isBase = list.get(0).isSymbol(baseTag);
boolean isPrefix = list.get(0).isSymbol(prefixTag);
// Old state has already been saved.
if (isBase) {
if (!item.isNode())
throwException("(base ...): not an RDF node for the base.", item);
if (!item.getNode().isURI())
throwException("(base ...): not an IRI for the base.", item);
String newBase = item.getNode().getURI();
if (baseURI != null)
baseURI = baseURI.resolve(newBase);
else
baseURI = IRIs.resolveIRI(newBase);
// Remember first base seen
if (topBase == null)
topBase = newBase;
return;
}
if (isPrefix) {
PrefixMapping newPrefixes = new PrefixMappingImpl();
PrefixMapping itemMappings = BuilderPrefixMapping.build(item);
// Add exising, overwrite with new
newPrefixes.setNsPrefixes(prefixes);
newPrefixes.setNsPrefixes(itemMappings);
prefixes = newPrefixes;
// Remember first prefix mapping seen.
if (topMap == null)
topMap = itemMappings;
return;
}
throwException("Inconsistent: " + list.shortString(), list);
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class Prologue method copy.
// public Prologue(PrefixMapping pmap, String base) {
// this.prefixMap = pmap;
// setBaseURI(base);
// }
public Prologue copy() {
PrefixMapping prefixMap = new PrefixMappingImpl();
prefixMap.setNsPrefixes(this.prefixMap);
return new Prologue(prefixMap, resolver);
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class GraphUnionRead method createPrefixMapping.
@Override
protected PrefixMapping createPrefixMapping() {
PrefixMapping pmap = new PrefixMappingImpl();
forEachGraph((g) -> {
PrefixMapping pmapNamedGraph = g.getPrefixMapping();
pmap.setNsPrefixes(pmapNamedGraph);
});
return pmap;
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class TestParameterizedSparqlString method test_param_string_constructor_8.
@Test
public void test_param_string_constructor_8() {
// Test constructors with predefined prefixes
PrefixMappingImpl prefixes = new PrefixMappingImpl();
prefixes.setNsPrefix("ex", "http://example.org");
ParameterizedSparqlString query = new ParameterizedSparqlString("", prefixes);
Assert.assertEquals(prefixes.getNsPrefixURI("ex"), query.getNsPrefixURI("ex"));
}
Aggregations