use of org.apache.jena.riot.out.NodeFormatter in project jena by apache.
the class ShLib method printShapes.
public static void printShapes(IndentedWriter out, Shapes shapes) {
NodeFormatter nodeFmt = ShLib.nodeFormatter(shapes);
printImports(out, nodeFmt, shapes);
printShapes(out, nodeFmt, shapes);
out.flush();
}
use of org.apache.jena.riot.out.NodeFormatter in project jena by apache.
the class CompactWriter method output.
public static void output(IndentedWriter out, NodeFormatter nodeFmt, ShapeOutputVisitor visitor, Shape sh) {
List<Target> targetImplicitClasses = sh.getTargets().stream().filter(t -> t.getTargetType() == TargetType.implicitClass).collect(Collectors.toList());
List<Target> targetClasses = sh.getTargets().stream().filter(t -> t.getTargetType() == TargetType.targetClass).collect(Collectors.toList());
if (targetImplicitClasses.isEmpty()) {
out.print("shape ");
nodeFmt.format(out, sh.getShapeNode());
if (!targetClasses.isEmpty()) {
out.print(" ->");
targetClasses.forEach(t -> {
out.print(" ");
nodeFmt.format(out, t.getObject());
});
}
} else {
if (targetImplicitClasses.size() > 1)
CompactWriter.notShaclc("Multiple implicit classes");
if (!targetClasses.isEmpty())
CompactWriter.notShaclc("Implicit classes and targetClass");
Target target = targetImplicitClasses.get(0);
out.print("shapeClass ");
nodeFmt.format(out, target.getObject());
}
out.println(" {");
out.incIndent();
sh.visit(visitor);
out.decIndent();
out.ensureStartOfLine();
out.println("}");
}
use of org.apache.jena.riot.out.NodeFormatter in project jena by apache.
the class CompactWriter method formatterPrefixMap.
private static NodeFormatter formatterPrefixMap(PrefixMapping prefixMapping) {
PrefixMap pmap = prefixMapWithStd(prefixMapping);
NodeFormatter nodeFmt = new NodeFormatterTTL(null, pmap);
return nodeFmt;
}
Aggregations