/** * Returns a new instance of NTriplesParser. */ public RDFParser getParser() { return new NTriplesParser(); } }
c = parseSubject(c); c = skipWhitespace(c); c = parsePredicate(c); c = skipWhitespace(c); c = parseObject(c); c = skipWhitespace(c); throwEOFException(); reportError("Expected '.', found: " + new String(Character.toChars(c)), NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); c = assertLineTerminates(c); if (!getParserConfig().get(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES) || getParserConfig().isNonFatalError( NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES)) reportError(rdfpe, NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); ignoredAnError = true; c = skipLine(c); Statement st = createStatement(subject, predicate, object);
protected int parseObject(int c) throws IOException, RDFParseException StringBuilder sb = getBuffer(); c = parseUriRef(c, sb); object = createURI(sb.toString()); c = parseNodeID(c, sb); object = createNode(sb.toString()); StringBuilder lang = getLanguageTagBuffer(); StringBuilder datatype = getDatatypeUriBuffer(); c = parseLiteral(c, sb, lang, datatype); object = createLiteral(sb.toString(), lang.toString(), datatype.toString()); throwEOFException();
protected int parseSubject(int c) throws IOException, RDFParseException { StringBuilder sb = new StringBuilder(100); // subject is either an uriref (<foo://bar>) or a nodeID (_:node1) if (c == '<') { // subject is an uriref c = parseUriRef(c, sb); subject = createURI(sb.toString()); } else if (c == '_') { // subject is a bNode c = parseNodeID(c, sb); subject = createNode(sb.toString()); } else if (c == -1) { throwEOFException(); } else { throw new RDFParseException("Expected '<' or '_', found: " + new String(Character.toChars(c)), lineNo, c); } return c; }
protected int parsePredicate(int c) throws IOException, RDFParseException { StringBuilder sb = new StringBuilder(100); // predicate must be an uriref (<foo://bar>) if (c == '<') { // predicate is an uriref c = parseUriRef(c, sb); predicate = createURI(sb.toString()); } else if (c == -1) { throwEOFException(); } else { throw new RDFParseException("Expected '<', found: " + new String(Character.toChars(c)), lineNo, c); } return c; }
throws IOException, RDFParseException, RDFHandlerException clear(); lineNo = 1; reportLocation(lineNo, 1); int c = readCodePoint(); c = skipWhitespace(c); c = skipLine(c); c = skipLine(c); c = parseTriple(c); c = skipWhitespace(c); clear();
final Path path = PathUtils.cleanHadoopPath(configuredPath, conf); final OutputCollector inferred = new OutputCollector(); final NTriplesParser parser = new NTriplesParser(); parser.setRDFHandler(inferred); if (fs.isDirectory(path)) { for (final FileStatus status : fs.listStatus(path)) { parser.parse(br, ""); br.close();
parse(new InputStreamReader(new BOMInputStream(in, false), StandardCharsets.UTF_8), baseURI);
protected Literal createLiteral(String label, String lang, String datatype) throws RDFParseException { try { label = NTriplesUtil.unescapeString(label); } catch (IllegalArgumentException e) { throw new RDFParseException(e, lineNo, -1); } if (lang.length() == 0) { lang = null; } if (datatype.length() == 0) { datatype = null; } IRI dtURI = null; if (datatype != null) { dtURI = createURI(datatype); } return super.createLiteral(label, lang, dtURI, lineNo, -1); }
throws IOException, RDFParseException, RDFHandlerException clear(); lineNo = 1; reportLocation(lineNo, 1); int c = readCodePoint(); c = skipWhitespace(c); c = skipLine(c); c = skipLine(c); c = parseTriple(c); c = skipWhitespace(c); clear();
protected int parseSubject(int c) throws IOException, RDFParseException { StringBuilder sb = new StringBuilder(100); // subject is either an uriref (<foo://bar>) or a nodeID (_:node1) if (c == '<') { // subject is an uriref c = parseUriRef(c, sb); subject = createURI(sb.toString()); } else if (c == '_') { // subject is a bNode c = parseNodeID(c, sb); subject = createNode(sb.toString()); } else if (c == -1) { throwEOFException(); } else { throw new RDFParseException("Expected '<' or '_', found: " + new String(Character.toChars(c)), lineNo, c); } return c; }
protected int parsePredicate(int c) throws IOException, RDFParseException { StringBuilder sb = new StringBuilder(100); // predicate must be an uriref (<foo://bar>) if (c == '<') { // predicate is an uriref c = parseUriRef(c, sb); predicate = createURI(sb.toString()); } else if (c == -1) { throwEOFException(); } else { throw new RDFParseException("Expected '<', found: " + new String(Character.toChars(c)), lineNo, c); } return c; }
parse(new InputStreamReader(new BOMInputStream(in, false), StandardCharsets.UTF_8), baseURI);
protected Literal createLiteral(String label, String lang, String datatype) throws RDFParseException { try { label = NTriplesUtil.unescapeString(label); } catch (IllegalArgumentException e) { throw new RDFParseException(e, lineNo, -1); } if (lang.length() == 0) { lang = null; } if (datatype.length() == 0) { datatype = null; } IRI dtURI = null; if (datatype != null) { dtURI = createURI(datatype); } return super.createLiteral(label, lang, dtURI, lineNo, -1); }
protected int parseObject(int c) throws IOException, RDFParseException StringBuilder sb = getBuffer(); c = parseUriRef(c, sb); object = createURI(sb.toString()); c = parseNodeID(c, sb); object = createNode(sb.toString()); StringBuilder lang = getLanguageTagBuffer(); StringBuilder datatype = getDatatypeUriBuffer(); c = parseLiteral(c, sb, lang, datatype); object = createLiteral(sb.toString(), lang.toString(), datatype.toString()); throwEOFException();
c = parseSubject(c); c = skipWhitespace(c); c = parsePredicate(c); c = skipWhitespace(c); c = parseObject(c); c = skipWhitespace(c); throwEOFException(); reportError("Expected '.', found: " + new String(Character.toChars(c)), NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); c = assertLineTerminates(c); if (!getParserConfig().get(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES) || getParserConfig().isNonFatalError( NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES)) reportError(rdfpe, NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); ignoredAnError = true; c = skipLine(c); Statement st = createStatement(subject, predicate, object);
/** * Returns a new instance of NTriplesParser. */ @Override public RDFParser getParser() { return new NTriplesParser(); } }