use of org.apache.jena.riot.system.stream.StreamManager in project jena by apache.
the class RDFParserBuilder method build.
/** Build an {@link RDFParser}. The parser takes it's configuration from this builder and can not then be changed.
* The source must be set.
* When a parser is used, it is takes the source and sends output to an {@link StreamRDF}.
* <p>
* Shortcuts:
* <ul>
* <li>{@link #parse(DatasetGraph)} - parse the source and output to a {@code DatasetGraph}
* <li>{@link #parse(Graph)} - parse the source and output to a {@code Graph}
* <li>{@link #parse(StreamRDF)} - parse the source and output to a {@code StreamRDF}
* </ul>
*
* @return RDFParser
*/
public RDFParser build() {
// Build what we can now - some things have to be built in the parser.
if (uri == null && path == null && content == null && inputStream == null && javaReader == null)
throw new RiotException("No source specified");
// Setup the HTTP client.
HttpClient client = buildHttpClient();
FactoryRDF factory$ = buildFactoryRDF();
ErrorHandler errorHandler$ = errorHandler;
if (errorHandler$ == null)
errorHandler$ = ErrorHandlerFactory.getDefaultErrorHandler();
if (path != null && baseUri == null)
baseUri = IRILib.filenameToIRI(path.toString());
if (path == null && baseUri == null && uri != null)
baseUri = uri;
StreamManager sMgr = streamManager;
if (sMgr == null)
sMgr = StreamManager.get(context);
// Can't build the profile here as it is Lang/conneg dependent.
return new RDFParser(uri, path, content, inputStream, javaReader, sMgr, client, hintLang, forceLang, baseUri, strict, checking, resolveURIs, canonicalLiterals, resolver, factory$, errorHandler$, context);
}
use of org.apache.jena.riot.system.stream.StreamManager in project jena by apache.
the class TestRDFParser method source_streamManager.
@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());
}
use of org.apache.jena.riot.system.stream.StreamManager in project jena by apache.
the class TestStreamManager method beforeClass.
@BeforeClass
public static void beforeClass() {
streamMgrStd = StreamManager.get();
streamMgrDir = new StreamManager();
// Not current directory.
streamMgrDir.addLocator(new LocatorFile(directory));
streamMgrDir.addLocator(new LocatorHTTP());
streamMgrHere = new StreamManager();
// Not current directory.
streamMgrHere.addLocator(new LocatorFile());
streamMgrHere.addLocator(new LocatorHTTP());
streamMgrNull = new StreamManager();
}
Aggregations