Refine search
@Override public void handleStatement(Statement statement) throws RDFHandlerException { try { sc.addStatement( statement.getSubject(), statement.getPredicate(), statement.getObject(), statement.getContext()); } catch (SailException e) { throw new RDFHandlerException(e); } }
@Override protected synchronized void removeWithoutCommit(Resource subject, URI predicate, Value object, Resource... contexts) throws RepositoryException { RDFHandler handler = new RDFInserter(removed); try { getDelegate().exportStatements(subject, predicate, object, true, handler, contexts); } catch (RDFHandlerException e) { if (e.getCause() instanceof RepositoryException) throw (RepositoryException) e.getCause(); throw new AssertionError(e); } added.remove(subject, predicate, object, contexts); }
public void close() throws IOException { try { if (writingStarted) { endRDF(); } } catch (RDFHandlerException e) { if (e.getCause() instanceof IOException) { throw (IOException)e.getCause(); } else { IOException ioe = new IOException(e.getMessage()); ioe.initCause(e); throw ioe; } } finally { writer.close(); } }
buildDeltaSets(forRemoval, forAddition); for (Statement st : forRemoval) { removeInferredStatement(st.getSubject(), st.getPredicate(), st.getObject(), contexts); Throwable cause = e.getCause(); if (cause instanceof SailException) { throw (SailException)cause;
@Override public void handleStatement(final Statement statement) throws RDFHandlerException { final Resource enumType = statement.getSubject(); // listHead will point to a type class of the enumeration. final URI listHead = (URI) statement.getObject(); if (!enumTypes.containsKey(enumType)) { enumTypes.put(enumType, new LinkedHashSet<Resource>()); } // listHead should point to a list of items that forms the // enumeration. try { final Set<Resource> enumeration = new LinkedHashSet<>(getList(listHead)); if (!enumeration.isEmpty()) { // Add this enumeration for this type. enumTypes.get(enumType).addAll(enumeration); } } catch (final QueryEvaluationException e) { throw new RDFHandlerException("Error getting enumeration list.", e); } } });
private void checkInterrupted() throws RDFHandlerException { if (isInterrupted) { throw new RDFHandlerException("RDFHandler took too long"); } } private void interrupt() {
@Override public void handleStatement(Statement st) throws RDFHandlerException { if (!writingStarted) { throw new RuntimeException("Document writing has not yet been started"); } try { Resource context = st.getContext(); if (inActiveContext && !contextsEquals(context, currentContext)) { closePreviousStatement(); closeActiveContext(); } if (!inActiveContext) { writer.writeEOL(); if (context != null) { writeResource(context); writer.write(" "); } writer.write("{"); writer.increaseIndentation(); currentContext = context; inActiveContext = true; } } catch (IOException e) { throw new RDFHandlerException(e); } super.handleStatement(st); }
/** * Load data from the inputstream given as first argument into the handler given as second argument. * * @param inStream input byte stream to read the data from; must be plain data in the format given as argument * @param handler handler to add the data to * @param format format to use for creating the parser * @throws RDFParseException * @throws IOException */ public void load(InputStream inStream, LoaderHandler handler, RDFFormat format) throws RDFParseException, IOException { try { RDFParser parser = createParser(format); parser.setRDFHandler(handler); parser.parse(inStream,configuration.getString(LoaderOptions.BASE_URI, "http://localhost/")); } catch (RDFHandlerException e) { log.error("error loading stream data in format {}: {}", format, e.getMessage()); } }
@Override public void run() { try { parser.parse(new BufferedReader(new FileReader(ntripleFile)), baseURI); } catch (RDFParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RDFHandlerException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } };
removeInferredStatement(st.getSubject(), st.getPredicate(), st.getObject(), contexts); Throwable t = e.getCause(); if (t instanceof SailException) { throw (SailException)t;
@Override public void handleStatement(final Statement statement) throws RDFHandlerException { final Resource type = statement.getSubject(); // head will point to a type that is part of the intersection. final URI head = (URI) statement.getObject(); if (!intersectionsProp.containsKey(type)) { intersectionsProp.put(type, new ArrayList<Set<Resource>>()); } // head should point to a list of items that forms the // intersection. try { final Set<Resource> intersection = new LinkedHashSet<>(getList(head)); if (!intersection.isEmpty()) { // Add this intersection for this type. There may be more // intersections for this type so each type has a list of // intersection sets. intersectionsProp.get(type).add(intersection); } } catch (final QueryEvaluationException e) { throw new RDFHandlerException("Error getting intersection list.", e); } } });
@Override public void handleStatement(final Statement st) throws RDFHandlerException { namespacesReady.countDown(); if (closed) throw new RDFHandlerException("Result closed"); try { queue.put(st); } catch (InterruptedException e) { throw new RDFHandlerException(e); } }
/** * Load data from the inputstream given as first argument into the handler given as second argument. * * @param inStream input byte stream to read the data from; must be plain data in the format given as argument * @param handler handler to add the data to * @param format format to use for creating the parser * @throws RDFParseException * @throws IOException */ public void load(InputStream inStream, LoaderHandler handler, RDFFormat format) throws RDFParseException, IOException { try { RDFParser parser = createParser(format); parser.setRDFHandler(handler); parser.parse(inStream,configuration.getString(LoaderOptions.BASE_URI, "http://localhost/")); } catch (RDFHandlerException e) { log.error("error loading stream data in format {}: {}", format, e.getMessage()); } }
} catch (RDFHandlerException e) { e.printStackTrace();
@Override public void handleStatement(final Statement st) throws RDFHandlerException { try { sailConnection.addStatement(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext()); } catch (SailException e) { throw new RDFHandlerException(e); } } }
if(nextStatement.getPredicate().equals(RDF.FIRST) || nextStatement.getPredicate().equals(RDF.REST)) if(!typedLists.contains(nextStatement.getSubject())) typedLists.add(nextStatement.getSubject()); if(e.getCause() != null && e.getCause().getCause() != null && e.getCause().getCause() instanceof UnloadableImportException) throw (UnloadableImportException)e.getCause().getCause();
protected final void error(@Nullable final Object message, @Nullable final Throwable ex) throws RDFHandlerException { final String string = message == null ? "ERROR" : message.toString(); if (ex != null) { SCRIPT_LOGGER.error(string, ex); throw new RDFHandlerException(string, ex); } else { SCRIPT_LOGGER.error(string); throw new RDFHandlerException(string); } }
/** * Load data from the reader given as first argument into the handler given as second argument. * * @param reader character stream to read the data from; must be plain data in the format given as argument * @param handler handler to add the data to * @param format format to use for creating the parser * @throws RDFParseException * @throws IOException */ public void load(Reader reader, LoaderHandler handler, RDFFormat format) throws RDFParseException, IOException { try { RDFParser parser = createParser(format); parser.setRDFHandler(handler); parser.parse(reader,configuration.getString(LoaderOptions.BASE_URI, "http://localhost/")); } catch (RDFHandlerException e) { log.error("error loading stream data in format {}: {}", format, e.getMessage()); } }
/** * Write contents of graph to writer using N3 serialization * * @param graph * @param writer */ public static void writeStatements(Collection<Statement> statements, OutputStream outputStream) { try { RDFWriter writer= Rio.createWriter(RDFFormat.N3, outputStream); writer.startRDF(); for(Statement statement:statements) { writer.handleStatement(statement); } writer.endRDF(); } catch (UnsupportedRDFormatException e) { e.printStackTrace(); } catch (RDFHandlerException e) { e.printStackTrace(); } }