private void checkStateForReceive() { if (closedByProducer || closedByConsumer) { throw new RiotException("Pipe closed"); } else if (consumerThread != null && !consumerThread.isAlive()) { throw new RiotException("Consumer dead"); } }
@Override public void read(InputStream in, String baseURI, ContentType ct, StreamRDF output, Context context) { XMLInputFactory xf = XMLInputFactory.newInstance() ; XMLStreamReader xReader ; try { xReader = xf.createXMLStreamReader(in) ; } catch (XMLStreamException e) { throw new RiotException("Can't initialize StAX parsing engine", e) ; } read(xReader, baseURI, output) ; }
@Override public void quad(Quad quad) { count++ ; if ( count > limit ) throw new RiotException("Limit ("+limit+") reached") ; super.quad(quad) ; }
/** report a warning - do not carry on */ @Override public void warning(String message, long line, long col) { throw new RiotException(fmtMessage(message, line, col)) ; }
/** report an error - do not carry on */ @Override public void error(String message, long line, long col) { throw new RiotException(fmtMessage(message, line, col)) ; }
@Override public void fatal(String message, long line, long col) { throw new RiotException(fmtMessage(message, line, col)) ; } }
/** Set the output format for sending RDF Datasets to the remote server. * This is used for HTTP PUT and POST to a dataset. * This must be a quads format. */ public RDFConnectionRemoteBuilder quadsFormat(String langQuads) { Objects.requireNonNull(langQuads); Lang lang = RDFLanguages.nameToLang(langQuads); if ( lang == null ) throw new RiotException("Language name not recognized: "+langQuads); quadsFormat(lang); return this; }
@Override public ResultSetReader create(Lang lang) { lang = Objects.requireNonNull(lang, "Language must not be null") ; // if ( lang.equals(SPARQLResultSetXML) ) return readerXML ; // if ( lang.equals(SPARQLResultSetJSON) ) return readerJSON ; if ( lang.equals(SPARQLResultSetCSV) ) return readerCSV ; if ( lang.equals(SPARQLResultSetTSV) ) return readerTSV ; throw new RiotException("Lang not registered (ResultSet reader)") ; } }
/** Set the output format for sending RDF Datasets to the remote server. * This is used for HTTP PUT and POST to a dataset. * This must be a quads format. */ public RDFConnectionRemoteBuilder quadsFormat(RDFFormat fmtQuads) { if ( ! RDFLanguages.isQuads(fmtQuads.getLang()) ) throw new RiotException("Not a language for RDF Datasets: "+fmtQuads); this.outputQuads = fmtQuads; return this; }
private static WriterDatasetRIOT createDatasetWriter$(RDFFormat serialization) { WriterDatasetRIOTFactory wf = RDFWriterRegistry.getWriterDatasetFactory(serialization); if ( wf == null ) throw new RiotException("No dataset writer for " + serialization); return wf.create(serialization); }
/** report a warning - do not carry on */ @Override public void warning(String message, long line, long col) { logWarning(message, line, col) ; throw new RiotException(fmtMessage(message, line, col)) ; }
/** report an error - do not carry on */ @Override public void error(String message, long line, long col) { logError(message, line, col) ; throw new RiotException(fmtMessage(message, line, col)) ; }
/** Get the graph writer factory associated with the language */ public static WriterGraphRIOTFactory getWriterGraphFactory(Lang lang) { RDFFormat serialization = defaultSerialization(lang) ; if ( serialization == null ) throw new RiotException("No default serialization for language " + lang) ; return getWriterGraphFactory(serialization) ; }
private static WriterGraphRIOT createGraphWriter$(RDFFormat serialization) { WriterGraphRIOTFactory wf = RDFWriterRegistry.getWriterGraphFactory(serialization); if ( wf == null ) throw new RiotException("No graph writer for " + serialization); return wf.create(serialization); }
private static WriterGraphRIOT createGraphWriter$(RDFFormat serialization) { WriterGraphRIOTFactory wf = RDFWriterRegistry.getWriterGraphFactory(serialization); if ( wf == null ) throw new RiotException("No graph writer for " + serialization); return wf.create(serialization); }
private String unescapeIRI(String iriStr) { try { return EscapeStr.unescape(iriStr, '\\', true); } catch (AtlasException ex) { throw new RiotException(ex.getMessage()); } }
private SPARQLResult readAny(InputStream input, Lang lang) { if ( ! ResultSetReaderRegistry.isRegistered(lang) ) throw new RiotException("Not registered as a SPARQL result set input syntax: "+lang); ResultSetReaderFactory factory = ResultSetReaderRegistry.getFactory(lang); if ( factory == null ) throw new RiotException("No ResultSetReaderFactory for "+lang); ResultSetReader reader = factory.create(lang); SPARQLResult rs = reader.readAny(input, context); return rs; } }
@Override public ResultSetWriter create(Lang lang) { lang = Objects.requireNonNull(lang, "Language must not be null"); // if ( lang.equals(SPARQLResultSetXML) ) return writerXML; // if ( lang.equals(SPARQLResultSetJSON) ) return writerJSON; if ( lang.equals(SPARQLResultSetCSV) ) return writerCSV; if ( lang.equals(SPARQLResultSetTSV) ) return writerTSV; if ( lang.equals(SPARQLResultSetText) ) return writerText; if ( lang.equals(SPARQLResultSetNone) ) return writerNone; throw new RiotException("Lang not registered (ResultSet writer)") ; } }
private Lang determinLang(TypedInputStream in, String url) { if ( in == null ) throw new RiotNotFoundException(url); Lang lang = forceLang; if ( lang == null ) { ContentType ct = WebContent.determineCT(in.getContentType(), hintLang, url); lang = RDFLanguages.contentTypeToLang(ct); } if ( lang == null ) throw new RiotException("Can't indentify the result set syntax from "+url); return lang; }
protected void checkQuad(Node graph, Node subject, Node predicate, Node object, long line, long col) { // Allow blank nodes - syntax may restrict more. if ( graph != null && !graph.isURI() && !graph.isBlank() ) { errorHandler.error("Graph name is not a URI or blank node: " + FmtUtils.stringForNode(graph), line, col); throw new RiotException("Bad graph name: " + graph); } checkTriple(subject, predicate, object, line, col); }