use of org.apache.jena.riot.system.PrefixMap in project jena by apache.
the class StoragePrefixesSimpleMem method accessForUpdate.
// Access or return a fresh, empty.
private PrefixMap accessForUpdate(Node graphName) {
graphName = canonicalGraphName(graphName);
PrefixMap pmap = map.get(graphName);
if (pmap == null) {
pmap = createPrefixMap();
map.put(graphName, pmap);
}
return pmap;
}
use of org.apache.jena.riot.system.PrefixMap in project jena by apache.
the class StoragePrefixesSimpleMem method access.
// Access or return the empty, dummy mapping.
private PrefixMap access(Node graphName) {
graphName = canonicalGraphName(graphName);
PrefixMap pmap = map.get(graphName);
if (pmap == null)
return PrefixMapZero.empty;
return pmap;
}
use of org.apache.jena.riot.system.PrefixMap in project jena by apache.
the class CompactWriter method print.
/**
* Write shapes with directives BASE/PREFIX/IMPORTS.
*/
public static void print(IndentedWriter out, Shapes shapes) {
// Output PrefixMap
PrefixMap graphPrefixMap = shapes.getPrefixMap();
// Formatter PrefixMap - with the std prefixes if not overridden.
PrefixMap pmapWithStd = SHACLC.withStandardPrefixes();
// Add to copy of standrard so it can override any standard settings.
pmapWithStd.putAll(graphPrefixMap);
NodeFormatter nodeFmt = new NodeFormatterTTL(null, pmapWithStd);
boolean someOutput = false;
// BASE - output if and only if there is exactly one.
String baseURI = shapes.getBaseURI();
if (baseURI != null) {
if (someOutput)
out.println();
RiotLib.writeBase(out, baseURI, true);
someOutput = true;
}
// PREFIX
if (!graphPrefixMap.isEmpty()) {
if (someOutput)
out.println();
RiotLib.writePrefixes(out, graphPrefixMap, true);
someOutput = true;
}
// IMPORTS
if (shapes.getImports() != null) {
if (!shapes.getImports().isEmpty()) {
if (someOutput)
out.println();
shapes.getImports().forEach(n -> {
out.print("IMPORTS ");
out.pad(WriterConst.PREFIX_IRI);
nodeFmt.format(out, n);
out.println();
});
}
}
PrefixMapping prefixMappingWithStd = Prefixes.adapt(pmapWithStd);
ShapeOutputVisitor visitor = new ShapeOutputVisitor(prefixMappingWithStd, nodeFmt, out);
shapes.iteratorAll().forEachRemaining(sh -> {
out.println();
writeOneShapeCompact(out, nodeFmt, visitor, sh);
// writeOneShapeCompactOrSkip(out, nodeFmt, visitor, sh);
});
out.flush();
}
use of org.apache.jena.riot.system.PrefixMap in project jena by apache.
the class TestDatasetPrefixes method dsg_prefixes_txn_3.
@Test
public void dsg_prefixes_txn_3() {
Assume.assumeTrue(supportsPromote);
DatasetGraph dsg = create();
Assume.assumeTrue(dsg.supportsTransactionAbort());
Txn.exec(dsg, TxnType.READ_PROMOTE, () -> {
PrefixMap pmap = dsg.prefixes();
pmap.add("ex", "http://example/2");
});
}
use of org.apache.jena.riot.system.PrefixMap in project jena by apache.
the class TestDatasetPrefixes method dsg_prefixes_txn_2.
// Legacy: TDBTransactionException is not under JenaTransactionException.
@Test(expected = JenaException.class)
public void dsg_prefixes_txn_2() {
Assume.assumeTrue(txnIsolation);
DatasetGraph dsg = create();
Txn.executeRead(dsg, () -> {
PrefixMap pmap = dsg.prefixes();
try {
// Write inside read.
// TIM prefixes are standalone, MRSW so they are thread safe but not tied to the TIM transaction lifecycle.
// No Isolation.
pmap.add("ex", "http://example/2");
} catch (JenaTransactionException | TDBTransactionException ex) {
throw ex;
}
});
}
Aggregations