Class StatementSources


  • public final class StatementSources
    extends java.lang.Object

    Utility class for working with StatementSources

    Since:
    0.8
    Version:
    6.0
    Author:
    Michael Grove
    • Method Detail

      • closeQuietly

        public static void closeQuietly​(StatementSource theSource)
        Quietly close the statement source, ignoring an exceptions and simply logging them rather than re-throwing.
        Parameters:
        theSource - the source to close.
      • toModel

        public static java.util.Set<Statement> toModel​(StatementSource theSrc)
                                                throws java.io.IOException
        Read the contents of a StatementSource into a graph. Be careful when calling this method as this will put the entire contents of the StatementSource into memory as a Graph, so large StatementSources could cause OOM errors.
        Parameters:
        theSrc - the source to read into a graph
        Returns:
        the contents of the source as a graph
        Throws:
        java.io.IOException - if there was an error while reading from the source
      • size

        public static long size​(StatementSource theSrc)
                         throws java.io.IOException
        Return the size (number of triples) in the StatementSource
        Parameters:
        theSrc - the source
        Returns:
        the size in triples
        Throws:
        java.io.IOException - if there was an error reading from the source
      • write

        public static long write​(StatementSource theSource,
                                 RDFFormat theFormat,
                                 java.io.OutputStream theOutputStream,
                                 ProgressReporter theReporter)
                          throws java.io.IOException
        Write the contents of the StatementSource in the specified format to the output stream
        Parameters:
        theSource - the source whose contents should be written
        theFormat - the RDF format to use when writing
        theOutputStream - the stream to write to
        Throws:
        java.io.IOException - if there was an error getting a statement from the source
      • write

        public static long write​(StatementSource theSource,
                                 RDFWriter theWriter,
                                 ProgressReporter theReporter)
                          throws java.io.IOException
        Write the contents of the StatementSource to the Rio writer
        Parameters:
        theSource - the source to write
        theWriter - the writer to write the source to
        Throws:
        java.io.IOException - if there is an error while writing