Search in sources :

Example 1 with ErrorHandlerTracking

use of org.apache.jena.riot.system.ErrorHandlerFactory.ErrorHandlerTracking in project jena by apache.

the class CmdLangParse method parseRIOT.

protected ParseRecord parseRIOT(RDFParserBuilder builder, String filename) {
    boolean checking = true;
    if (modLangParse.explicitChecking())
        checking = true;
    if (modLangParse.explicitNoChecking())
        checking = false;
    builder.checking(checking);
    if (checking)
        builder.strict(true);
    // Should use ErrorHandlerRecorder
    ErrorHandlerTracking errHandler = ErrorHandlerFactory.errorHandlerTracking(ErrorHandlerFactory.stdLogger, true, modLangParse.stopOnWarnings());
    builder.errorHandler(errHandler);
    // Make into a cmd flag. (input and output subflags?)
    // If input is "label, then output using NodeToLabel.createBNodeByLabelRaw() ;
    // else use NodeToLabel.createBNodeByLabel() ;
    // Also, as URI.
    final boolean labelsAsGiven = false;
    // labels = NodeToLabel.createBNodeByLabelEncoded() ;
    if (labelsAsGiven)
        builder.labelToNode(LabelToNode.createUseLabelAsGiven());
    StreamRDF s = outputStream;
    if (setup != null)
        s = RDFSFactory.streamRDFS(s, setup);
    StreamRDFCounting sink = StreamRDFLib.count(s);
    s = null;
    boolean successful = true;
    modTime.startTimer();
    RDFParser parser = builder.build();
    try {
        sink.start();
        parser.parse(sink);
        successful = true;
    } catch (RiotNotFoundException ex) {
        errHandler.error(ex.getMessage(), -1, -1);
        successful = false;
    } catch (RiotException ex) {
        successful = false;
    } catch (IRIException ex) {
        successful = false;
    }
    sink.finish();
    long x = modTime.endTimer();
    ParseRecord outcome = new ParseRecord(filename, successful, x, sink.countTriples(), sink.countQuads(), errHandler);
    return outcome;
}
Also used : IRIException(org.apache.jena.irix.IRIException) StreamRDF(org.apache.jena.riot.system.StreamRDF) StreamRDFCounting(org.apache.jena.riot.lang.StreamRDFCounting) ErrorHandlerTracking(org.apache.jena.riot.system.ErrorHandlerFactory.ErrorHandlerTracking)

Aggregations

IRIException (org.apache.jena.irix.IRIException)1 StreamRDFCounting (org.apache.jena.riot.lang.StreamRDFCounting)1 ErrorHandlerTracking (org.apache.jena.riot.system.ErrorHandlerFactory.ErrorHandlerTracking)1 StreamRDF (org.apache.jena.riot.system.StreamRDF)1