Class 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 Detail

      • BYTE_PER_STATEMENT

        public static long BYTE_PER_STATEMENT
    • 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.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 parse
        theHandler - 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