Package com.complexible.common.rdf.rio
Class RDFStreams
- java.lang.Object
-
- com.complexible.common.rdf.rio.RDFStreams
-
public final class RDFStreams extends java.lang.Object
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 Modifier and Type Field Description static long
BYTE_PER_STATEMENT
static RDFStream
EMPTY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
estimatedCount(long theBytes, RDFFormat theFormat)
static long
estimatedCount(java.lang.Iterable<RDFStream> theStreams)
static RDFStreamBuilder
forFile(java.nio.file.Path theFile)
static RDFStreamBuilder
forFiles(java.nio.file.Path... theFiles)
static RDFStreamBuilder
forFiles(java.util.Collection<java.nio.file.Path> theFiles)
static java.lang.String
formatParseException(RDFStream theStream, java.lang.Exception theError)
static RDFStream
forStatements(java.lang.Iterable<Statement> theStatements, Resource theContext)
static RDFStream
forStatements(java.util.Iterator<Statement> theStatements, Resource theContext)
static RDFStream
forStatements(java.util.Iterator<Statement> theStatements, Resource theContext, long estimatedSize)
static RDFStreamBuilder
forStream(java.io.InputStream theStream)
static boolean
hasContext(java.lang.Iterable<RDFStream> theStreams)
static long
length(java.lang.Iterable<RDFStream> theStreams)
static java.util.Set<Statement>
parse(java.util.List<RDFStream> theStreams)
Parses the contents of the given streams and returns a set of statements.static void
parse(java.util.List<RDFStream> theStreams, RDFHandler theHandler)
Parses the contents of the given streams with the specified handler and closes all the streams at the end.static java.util.List<Namespace>
parseNamespaces(java.util.List<RDFStream> theStreams)
Parses the namespaces from the given streams and returns all the namespaces parsed.
-
-
-
Field Detail
-
BYTE_PER_STATEMENT
public static long BYTE_PER_STATEMENT
-
EMPTY
public static final RDFStream EMPTY
-
-
Method Detail
-
forFile
public static RDFStreamBuilder forFile(java.nio.file.Path theFile)
-
forFiles
public static RDFStreamBuilder forFiles(java.nio.file.Path... theFiles)
-
forFiles
public static RDFStreamBuilder forFiles(java.util.Collection<java.nio.file.Path> theFiles)
-
forStream
public static RDFStreamBuilder forStream(java.io.InputStream theStream)
-
forStatements
public static RDFStream forStatements(java.lang.Iterable<Statement> theStatements, Resource theContext)
-
forStatements
public static RDFStream forStatements(java.util.Iterator<Statement> theStatements, Resource theContext)
-
forStatements
public static RDFStream forStatements(java.util.Iterator<Statement> theStatements, Resource theContext, long estimatedSize)
-
hasContext
public static boolean hasContext(java.lang.Iterable<RDFStream> theStreams)
-
length
public static long length(java.lang.Iterable<RDFStream> theStreams)
-
estimatedCount
public static long estimatedCount(java.lang.Iterable<RDFStream> theStreams)
-
estimatedCount
public static long estimatedCount(long theBytes, RDFFormat theFormat)
-
formatParseException
public static java.lang.String formatParseException(RDFStream theStream, java.lang.Exception theError)
-
parse
public static void parse(java.util.List<RDFStream> theStreams, RDFHandler theHandler) throws InvalidRDF, java.io.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:
InvalidRDF
java.io.IOException
-
parse
public static java.util.Set<Statement> parse(java.util.List<RDFStream> theStreams) throws InvalidRDF, java.io.IOException
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:
InvalidRDF
java.io.IOException
-
parseNamespaces
public static java.util.List<Namespace> parseNamespaces(java.util.List<RDFStream> theStreams) throws InvalidRDF
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
-
-