Class RDFWriters

java.lang.Object
com.stardog.stark.io.RDFWriters

public final class RDFWriters extends Object

Utility methods for working with RDFWriter

Since:
1.0
Version:
1.0
Author:
Michael Grove
  • Method Details

    • to

      public static Optional<RDFWriter> to(@Nonnull OutputStream theOutput, @Nonnull RDFFormat theFormat)
      Create a new writer to write in the specified format with the default options.
      Parameters:
      theOutput - the output to write to
      theFormat - the format to write in
      Returns:
      the `RDFWriter` to use for writing
      See Also:
      Implementation Notes:
      The `OutputStream` is *not* closed when writing is complete
    • to

      public static Optional<RDFWriter> to(@Nonnull OutputStream theOutput, @Nonnull RDFFormat theFormat, @Nonnull Iterable<Namespace> theNamespaces)
      Create a new writer to write in the specified format with the given namespaces.
      Parameters:
      theOutput - the output to write to
      theFormat - the format to write in
      theNamespaces - the namespaces for writing
      Returns:
      the `RDFWriter` to use for writing
      See Also:
      Implementation Notes:
      The `OutputStream` is *not* closed when writing is complete
    • to

      public static Optional<RDFWriter> to(@Nonnull OutputStream theOutput, @Nonnull RDFFormat theFormat, @Nonnull Options theWriterOptions)
      Create a new writer to write in the specified format with the given options.
      Parameters:
      theOutput - the output to write to
      theFormat - the format to write in
      theWriterOptions - the options for writing
      Returns:
      the `RDFWriter` to use for writing
      See Also:
      Implementation Notes:
      The `OutputStream` is *not* closed when writing is complete
    • write

      public static long write(@Nonnull RDFWriter theWriter, @Nonnull Iterable<Statement> theStmts)
      Write the given statements to the writer
      Parameters:
      theWriter - the RDFWriter to write to
      theStmts - the statements to write
      Implementation Notes:
      The writer will be started and ended before and after writing the given statements.
    • write

      public static long write(@Nonnull RDFWriter theWriter, @Nonnull Iterable<Statement> theStmts, @Nonnull Iterable<Namespace> theNamespaces)
      Write the given statements and namespaces to the writer
      Parameters:
      theWriter - the RDFWriter to write to
      theStmts - the statements to write
      theNamespaces - the namespaces to use for converting IRIs to QNames
      Implementation Notes:
      The writer will be started and ended before and after writing the given statements.
    • write

      public static long write(@Nonnull OutputStream theStream, @Nonnull RDFFormat theFormat, @Nonnull Iterable<Statement> theStmts)
      Writes the statements similar to write(RDFWriter, Iterable, Iterable).
      Returns:
      the number of statements written (duplicate statements will be counted as many times as they appear)
      Throws:
      IllegalArgumentException - if a writer supporting the given format is not found
    • write

      public static long write(@Nonnull OutputStream theStream, @Nonnull RDFFormat theFormat, @Nonnull Iterable<Statement> theStmts, @Nonnull Iterable<Namespace> theNamespaces)
      Writes the statements similar to write(RDFWriter, Iterable, Iterable).
      Returns:
      the number of statements written (duplicate statements will be counted as many times as they appear)
      Throws:
      IllegalArgumentException - if a writer supporting the given format is not found
    • writeGrouped

      public static long writeGrouped(@Nonnull OutputStream theStream, @Nonnull RDFFormat theFormat, @Nonnull Iterable<Statement> theStmts, @Nonnull Iterable<Namespace> theNamespaces)
      Writes the statements similar to write(RDFWriter, Iterable, Iterable) but first groups the statements by their subjects and predicates so the output will look better (if the writer supports this kind of optimization).
      Returns:
      the number of statements written (duplicate statements will be counted as many times as they appear)
    • writeGrouped

      public static long writeGrouped(@Nonnull RDFWriter theWriter, @Nonnull Iterable<Statement> theStmts, @Nonnull Iterable<Namespace> theNamespaces)
      Writes the statements similar to write(RDFWriter, Iterable, Iterable) but first groups the statements by their subjects and predicates so the output will look better (if the writer supports this kind of optimization).
      Returns:
      the number of statements written (duplicate statements will be counted as many times as they appear)
    • toString

      @Nonnull public static String toString(@Nonnull Iterable<Statement> theStatements, @Nonnull RDFFormat theFormat)
      Serialize the statements in the given format as a String.
      Parameters:
      theStatements - the statements to serialize
      theFormat - the RDF format to serialize into
      Returns:
      the statements serialized in the given RDF format
      See Also:
      Implementation Notes:
      Since this serializes the statements into a String in-memory, this is not suitable for serialization of large graphs
    • toString

      @Nonnull public static String toString(@Nonnull Iterable<Statement> theStatements, @Nonnull RDFFormat theFormat, @Nonnull Iterable<Namespace> theNamespaces)
      Serialize the statements in the given format as a String.
      Parameters:
      theStatements - the statements to serialize
      theFormat - the RDF format to serialize into
      theNamespaces - the namespaces to use for converting IRIs to QNames
      Returns:
      the statements serialized in the given RDF format
      See Also:
      Implementation Notes:
      Since this serializes the statements into a String in-memory, this is not suitable for serialization of large graphs
    • to

      public static RDFWriters.RDFWriterConfig to(OutputStream theStream)