public Model read(Model model, InputStream is, Lang lang, String baseURI, ErrorHandler errorHandler, ParserProfile parserProfile) { if (model == null) throw new IllegalArgumentException("Model must be not null"); if (is == null) throw new IllegalArgumentException("InputStream must be not null"); if (lang == null) throw new IllegalArgumentException("Lang must be not null"); ReaderRIOT parser = RDFDataMgr.createReader(lang); parser.setErrorHandler(errorHandler); parser.setParserProfile(parserProfile); parser.read(is, baseURI, null, StreamRDFLib.graph(model.getGraph()), null); return model; }
/** Call the reader, from either an InputStream or a Reader */ private static void read(ReaderRIOT readerRiot, InputStream inputStream, Reader javaReader, String baseUri, Context context, ContentType ct, StreamRDF destination) { if ( inputStream != null && javaReader != null ) throw new InternalErrorException("Both inputStream and javaReader are non-null"); if ( inputStream != null ) { readerRiot.read(inputStream, baseUri, ct, destination, context); return; } if ( javaReader != null ) { readerRiot.read(javaReader, baseUri, ct, destination, context); return; } throw new InternalErrorException("Both inputStream and javaReader are null"); }
private static void process(StreamRDF destination, Reader in, String baseUri, Lang lang, Context context ) { // Not as good as from an InputStream ContentType ct = determineCT(baseUri, null, lang) ; if ( ct == null ) throw new RiotException("Failed to determine the content type: (URI="+baseUri+" : hint="+lang+")") ; ReaderRIOT reader = getReader(ct) ; if ( reader == null ) throw new RiotException("No parser registered for content type: "+ct.getContentType()) ; reader.read(in, baseUri, ct, destination, context) ; }
private static void process(StreamRDF destination, TypedInputStream in, String baseUri, Lang hintLang, Context context) { ContentType ct = determineCT(baseUri, in.getContentType(), hintLang) ; if ( ct == null ) throw new RiotException("Failed to determine the content type: (URI="+baseUri+" : stream="+in.getContentType()+" : hint="+hintLang+")") ; ReaderRIOT reader = getReader(ct) ; if ( reader == null ) throw new RiotException("No parser registered for content type: "+ct.getContentType()) ; reader.read(in, baseUri, ct, destination, context) ; }
@Test public void trix_direct() { ReaderRIOT r = new ReaderTriX(RiotLib.dftProfile(), ErrorHandlerFactory.errorHandlerNoWarnings); InputStream in = IO.openFile(fInput) ; DatasetGraph dsg = DatasetGraphFactory.create() ; //StreamRDF stream = StreamRDFLib.writer(System.out) ; StreamRDF stream = StreamRDFLib.dataset(dsg) ; stream.start(); r.read(in, null, null, stream, null) ; stream.finish(); if ( fExpected != null ) { DatasetGraph dsg2 = RDFDataMgr.loadDatasetGraph(fExpected) ; boolean b = IsoMatcher.isomorphic(dsg, dsg2) ; if ( ! b ) { Assert.fail("Not isomorphic") ; } } }