private void throwEOFException() throws RDFParseException { throw new RDFParseException("Unexpected end of file"); }
protected void throwEOFException() throws RDFParseException { throw new RDFParseException("Unexpected end of file"); }
private void throwEOFException() throws RDFParseException { throw new RDFParseException("Unexpected end of file"); }
protected void throwEOFException() throws RDFParseException { throw new RDFParseException("Unexpected end of file"); }
private void handleException() throws IOException, RDFHandlerException, RDFParseException { if (exception != null) { try { throw exception; } catch (IOException e) { throw e; } catch (RDFHandlerException e) { throw e; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RDFParseException(e); } } }
/** * Reports a fatal error with associated line- and column number to the * registered ParseErrorListener, if any, and throws a * <tt>ParseException</tt> afterwards. * * @since 2.7.1 */ public static void reportFatalError(String msg, long lineNo, long columnNo, ParseErrorListener errListener) throws RDFParseException { if (errListener != null) { errListener.fatalError(msg, lineNo, columnNo); } throw new RDFParseException(msg, lineNo, columnNo); }
private char readLocalEscapedChar() throws RDFParseException, IOException { int c = readCodePoint(); if (TurtleUtil.isLocalEscapedChar(c)) { return (char)c; } else { throw new RDFParseException("found '" + new String(Character.toChars(c)) + "', expected one of: " + Arrays.toString(TurtleUtil.LOCAL_ESCAPED_CHARS)); } }
/** * Gets the namespace that is associated with the specified prefix or throws * an {@link RDFParseException}. * * @throws RDFParseException * if no namespace is associated with this prefix */ protected String getNamespace(String prefix) throws RDFParseException { if (namespaceTable.containsKey(prefix)) return namespaceTable.get(prefix); String msg = "Namespace prefix '" + prefix + "' used but not defined"; if ("".equals(prefix)) { msg = "Default namespace used but not defined"; } reportFatalError(msg); throw new RDFParseException(msg); }
private void await(final CountDownLatch latch) throws RDFParseException, IOException, RDFHandlerException { try { latch.await(); } catch (InterruptedException e) { handleException(); throw new RDFParseException(e); } handleException(); }
@Override public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException { try { parser.parseQueryResult(in); } catch (QueryResultParseException e) { throw new RDFParseException(e); } catch (QueryResultHandlerException e) { throw new RDFHandlerException(e); } }
@Override protected Resource parseImplicitBlank() throws IOException, RDFParseException, RDFHandlerException { if (isAllowBlankNodes()) { return super.parseImplicitBlank(); } else { throw new RDFParseException("blank nodes not allowed in data block"); } }
@Override protected BNode parseNodeID() throws IOException, RDFParseException { if (isAllowBlankNodes()) { return super.parseNodeID(); } else { throw new RDFParseException("blank nodes not allowed in data block"); } }
@Override public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException { try { parser.parseQueryResult(in); } catch (QueryResultParseException e) { throw new RDFParseException(e); } catch (QueryResultHandlerException e) { throw new RDFHandlerException(e); } }
@Override public void parse(Reader reader, String baseURI) throws RDFParseException, RDFHandlerException { refreshSettings(); try { streamProcessor.process(reader, baseURI); } catch (ParseException e) { throw new RDFParseException(e); } }
private void parse(StreamSource source, String baseURI) throws IOException, RDFParseException, RDFHandlerException { CountDownLatch latch = new CountDownLatch(1); PipedInputStream pipe = new PipedInputStream(); PipedOutputStream out = new PipedOutputStream(pipe); try { parse(pipe, baseURI, latch); transformer.transform(source, new StreamResult(out)); } catch (TransformerException e) { handleException(); throw new RDFParseException(e); } finally { out.close(); } await(latch); }
@Override public void parse(final Reader reader, final String baseURI) throws IOException, RDFParseException, RDFHandlerException { final SesameTripleCallback callback = new SesameTripleCallback(getRDFHandler(), valueFactory, getParserConfig(), getParseErrorListener()); final JsonLdOptions options = new JsonLdOptions(baseURI); options.useNamespaces = true; try { JsonLdProcessor.toRDF(JsonUtils.fromReader(reader), callback, options); } catch (final JsonLdError e) { throw new RDFParseException("Could not parse JSONLD", e); } catch (final JsonParseException e) { throw new RDFParseException("Could not parse JSONLD", e); } catch (final RuntimeException e) { if (e.getCause() != null && e.getCause() instanceof RDFParseException) { throw (RDFParseException) e.getCause(); } throw e; } }
@Override public void parse(final InputStream in, final String baseURI) throws IOException, RDFParseException, RDFHandlerException { final SesameTripleCallback callback = new SesameTripleCallback(getRDFHandler(), valueFactory, getParserConfig(), getParseErrorListener()); final JsonLdOptions options = new JsonLdOptions(baseURI); options.useNamespaces = true; try { JsonLdProcessor.toRDF(JsonUtils.fromInputStream(in), callback, options); } catch (final JsonLdError e) { throw new RDFParseException("Could not parse JSONLD", e); } catch (final JsonParseException e) { throw new RDFParseException("Could not parse JSONLD", e); } catch (final RuntimeException e) { if (e.getCause() != null && e.getCause() instanceof RDFParseException) { throw (RDFParseException) e.getCause(); } throw e; } }
/** * Parses the data from the supplied Reader, using the supplied baseURI to * resolve any relative URI references. * * @param reader The Reader from which to read the data. * @param baseURI The URI associated with the data in the InputStream. * @throws java.io.IOException If an I/O error occurred while data was read from the InputStream. * @throws org.openrdf.rio.RDFParseException * If the parser has found an unrecoverable parse error. * @throws org.openrdf.rio.RDFHandlerException * If the configured statement handler has encountered an * unrecoverable error. */ @Override public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException { Preconditions.checkNotNull(baseURI); setBaseURI(baseURI); try { parseCalendar(new CalendarBuilder().build(reader)); } catch (ParserException e) { throw new RDFParseException(e); } }
public void parse(final Reader reader, final String baseURI) throws IOException, RDFParseException, RDFHandlerException { if (null == rdfHandler) { throw new IllegalStateException("RDF handler has not been set"); } String s = toString(reader); Collection<Statement> g = RDFJSON.rdfJsonToGraph(s); if(g == null) { throw new RDFParseException("Could not parse JSON RDF Graph"); } rdfHandler.startRDF(); for (Statement statement : g) { rdfHandler.handleStatement(statement); } rdfHandler.endRDF(); }
@Override public void parse(final Reader reader, final String baseURI) throws IOException, RDFParseException, RDFHandlerException { final QuadSink sink = new SesameSink(this.rdfHandler, this.valueFactory); try { final CharSink parser = JsonLdParser.connect(sink); parser.startStream(); final char[] buffer = new char[4096]; while (true) { final int length = reader.read(buffer); if (length < 0) { break; } parser.process(buffer, 0, length); } parser.endStream(); } catch (final ParseException ex) { throw new RDFParseException(ex.getMessage(), ex); } }