@Deprecated private static void processFromTypedInputStream(StreamRDF sink, TypedInputStream in, String baseUri, Lang hintLang, Context context) { // If the input stream comes with a content type, use that in preference to the hint (compatibility). // Except for text/plain. // Do here, which duplicates RDFParser, because "TypedInputStream" gets lost at RDFParser if ( in.getContentType() != null ) { // Special case of text/plain. ContentType ct = WebContent.determineCT(in.getContentType(), hintLang, null); Lang lang2 = RDFLanguages.contentTypeToLang(ct); hintLang = lang2 ; } RDFParser.create() .source(in) .base(baseUri) .lang(hintLang) // We made the decision above. .forceLang(hintLang) .context(context) .parse(sink); } // ---- Support for RDFDataMgr.parse only.
public ParseRecord parseFile(String filename) { String baseURI = modLangParse.getBaseIRI() ; RDFParserBuilder builder = RDFParser.create(); if ( baseURI != null ) builder.base(baseURI); if ( modLangParse.getLang() != null ) // Always use the command line specified syntax. builder.forceLang(modLangParse.getLang()); else { // Otherwise, use the command selected language, with N-Quads as the ultimate fallback. Lang lang = dftLang() ; if ( lang == null ) lang = Lang.NQUADS; // Fall back lang if RIOT can't guess it. builder.lang(lang); } // Set the source. if ( filename.equals("-") ) { if ( baseURI == null ) { baseURI = "http://base/"; builder.base(baseURI); } builder.source(System.in); } else { builder.source(filename); } return parseRIOT(builder, filename); }
/** Parse, forcing the language.*/ public static void parse(DatasetGraph dataset, String uri, String base, Lang lang) { RDFParser.create().forceLang(lang).source(uri).base(base).build().parse(dataset); }
public ParseRecord parseFile(String filename) { String baseURI = modLangParse.getBaseIRI() ; RDFParserBuilder builder = RDFParser.create(); if ( baseURI != null ) builder.base(baseURI); if ( modLangParse.getLang() != null ) // Always use the command line specified syntax. builder.forceLang(modLangParse.getLang()); else { // Otherwise, use the command selected language, with N-Quads as the ultimate fallback. Lang lang = dftLang() ; if ( lang == null ) lang = Lang.NQUADS; // Fall back lang if RIOT can't guess it. builder.lang(lang); } // Set the source. if ( filename.equals("-") ) { if ( baseURI == null ) { baseURI = "http://base/"; builder.base(baseURI); } builder.source(System.in); } else { builder.source(filename); } return parseRIOT(builder, filename); }
public static void parse(Graph graph, String uri, String base, Lang lang) { RDFParser.create().forceLang(lang).source(uri).base(base).build().parse(graph); }
@Test public void source_uri_force_lang() { Graph graph = GraphFactory.createGraphMem(); RDFParser.create().source("file:"+DIR+"data.rdf").forceLang(Lang.TTL).parse(graph); assertEquals(3, graph.size()); }
RDFParser parser = RDFParser .source(input.getInputStream()) .forceLang(lang) .build(); if ( loadBuffered ) {
@Test public void source_streamManager() { StreamManager sMgr = new StreamManager(); sMgr.addLocator(new LocatorFile(DIR)) ; Graph graph = GraphFactory.createGraphMem(); RDFParser.create().streamManager(sMgr).source("file:data.rdf").forceLang(Lang.TTL).parse(graph); assertEquals(3, graph.size()); }