Search in sources :

Example 6 with NodeFormatter

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();
}
Also used : NodeFormatter(org.apache.jena.riot.out.NodeFormatter)

Example 7 with NodeFormatter

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("}");
}
Also used : CollectionUtils(org.apache.jena.atlas.lib.CollectionUtils) SHACLC(org.apache.jena.shacl.compact.SHACLC) RiotLib(org.apache.jena.riot.system.RiotLib) Collection(java.util.Collection) Prefixes(org.apache.jena.riot.system.Prefixes) IndentedLineBuffer(org.apache.jena.atlas.io.IndentedLineBuffer) NodeFormatterTTL(org.apache.jena.riot.out.NodeFormatterTTL) PrefixMapping(org.apache.jena.shared.PrefixMapping) Collectors(java.util.stream.Collectors) IndentedWriter(org.apache.jena.atlas.io.IndentedWriter) Constraint(org.apache.jena.shacl.parser.Constraint) List(java.util.List) ShaclException(org.apache.jena.shacl.ShaclException) PrefixMap(org.apache.jena.riot.system.PrefixMap) WriterConst(org.apache.jena.riot.writer.WriterConst) Target(org.apache.jena.shacl.engine.Target) TargetType(org.apache.jena.shacl.engine.TargetType) Shape(org.apache.jena.shacl.parser.Shape) NodeFormatter(org.apache.jena.riot.out.NodeFormatter) Shapes(org.apache.jena.shacl.Shapes) Target(org.apache.jena.shacl.engine.Target)

Example 8 with NodeFormatter

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;
}
Also used : PrefixMap(org.apache.jena.riot.system.PrefixMap) NodeFormatter(org.apache.jena.riot.out.NodeFormatter) NodeFormatterTTL(org.apache.jena.riot.out.NodeFormatterTTL)

Aggregations

NodeFormatter (org.apache.jena.riot.out.NodeFormatter)8 NodeFormatterTTL (org.apache.jena.riot.out.NodeFormatterTTL)5 PrefixMap (org.apache.jena.riot.system.PrefixMap)3 IndentedWriter (org.apache.jena.atlas.io.IndentedWriter)2 Node (org.apache.jena.graph.Node)2 PrefixMapping (org.apache.jena.shared.PrefixMapping)2 Collection (java.util.Collection)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 IndentedLineBuffer (org.apache.jena.atlas.io.IndentedLineBuffer)1 CollectionUtils (org.apache.jena.atlas.lib.CollectionUtils)1 Prefixes (org.apache.jena.riot.system.Prefixes)1 RiotLib (org.apache.jena.riot.system.RiotLib)1 WriterConst (org.apache.jena.riot.writer.WriterConst)1 ShaclException (org.apache.jena.shacl.ShaclException)1 Shapes (org.apache.jena.shacl.Shapes)1 SHACLC (org.apache.jena.shacl.compact.SHACLC)1 Target (org.apache.jena.shacl.engine.Target)1 TargetType (org.apache.jena.shacl.engine.TargetType)1 Constraint (org.apache.jena.shacl.parser.Constraint)1