Package com.complexible.common.rdf.rio
Class RDFStreams
java.lang.Object
com.complexible.common.rdf.rio.RDFStreams
A simple interface for parsers. A parser represents an atomic unit of input that will generate triples.
- Since:
- 2.0
- Version:
- 6.0
- Author:
- Evren Sirin
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic longestimatedCount(long theBytes, RDFFormat theFormat) static longestimatedCount(Iterable<RDFStream> theStreams) static RDFStreamBuilderstatic RDFStreamBuilderstatic RDFStreamBuilderforFiles(Collection<Path> theFiles) static StringformatParseException(RDFStream theStream, Exception theError) static RDFStreamforStatements(Iterable<Statement> theStatements, Resource theContext) static RDFStreamforStatements(Iterator<Statement> theStatements, Resource theContext) static RDFStreamforStatements(Iterator<Statement> theStatements, Resource theContext, long estimatedSize) static RDFStreamBuilderforStream(InputStream theStream) static booleanhasContext(Iterable<RDFStream> theStreams) static longParses the contents of the given streams and returns a set of statements.static voidparse(List<RDFStream> theStreams, RDFHandler theHandler) Parses the contents of the given streams with the specified handler and closes all the streams at the end.parseNamespaces(List<RDFStream> theStreams) Parses the namespaces from the given streams and returns all the namespaces parsed.
-
Field Details
-
BYTE_PER_STATEMENT
public static long BYTE_PER_STATEMENT -
EMPTY
-
-
Method Details
-
forFile
-
forFiles
-
forFiles
-
forStream
-
forStatements
-
forStatements
-
forStatements
-
hasContext
-
length
-
estimatedCount
-
estimatedCount
-
formatParseException
-
parse
public static void parse(List<RDFStream> theStreams, RDFHandler theHandler) throws InvalidRDF, IOException Parses the contents of the given streams with the specified handler and closes all the streams at the end. If an error occurs while parsing one of the streams remaining streams will not be parsed and an exception will be thrown. All the streams will be closed regardless of any errors.- Parameters:
theStreams- streams to parsetheHandler- handler- Throws:
InvalidRDFIOException
-
parse
Parses the contents of the given streams and returns a set of statements. If an error occurs while parsing one of the streams remaining streams will not be parsed and an exception will be thrown. All the streams will be closed regardless of any errors.- Parameters:
theStreams- streams to parse- Returns:
- set of statements parsed from all the streams
- Throws:
InvalidRDFIOException
-
parseNamespaces
Parses the namespaces from the given streams and returns all the namespaces parsed. This function will only parse the namespaces declared at the beginning of the stream and will stop parsing as soon as the first statement is parsed. Therefore, it can efficiently parse the namespaces from very large streams without processing the whole stream but if a stream has namespace declarations mixed with statements they will not be returned in the results. If an error occurs while parsing one of the streams remaining streams will not be parsed and an exception will be thrown. All the streams will be closed regardless of any errors.- Parameters:
theStreams- streams to parse- Returns:
- set of statements parsed from all the streams
- Throws:
InvalidRDF
-