Package com.stardog.stark.io
Class RDFWriters
- java.lang.Object
-
- com.stardog.stark.io.RDFWriters
-
public final class RDFWriters extends java.lang.Object
Utility methods for working with
RDFWriter
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RDFWriters.RDFWriterConfig
Write builder forRDFWriter
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RDFWriters.RDFWriterConfig
to(java.io.OutputStream theStream)
static java.util.Optional<RDFWriter>
to(java.io.OutputStream theOutput, RDFFormat theFormat)
static java.util.Optional<RDFWriter>
to(java.io.OutputStream theOutput, RDFFormat theFormat, Options theWriterOptions)
static java.util.Optional<RDFWriter>
to(java.io.OutputStream theOutput, RDFFormat theFormat, java.lang.Iterable<Namespace> theNamespaces)
static java.lang.String
toString(java.lang.Iterable<Statement> theStatements, RDFFormat theFormat)
Serialize the statements in the givenformat
as aString
.static java.lang.String
toString(java.lang.Iterable<Statement> theStatements, RDFFormat theFormat, java.lang.Iterable<Namespace> theNamespaces)
Serialize the statements in the givenformat
as aString
.static long
write(RDFWriter theWriter, java.lang.Iterable<Statement> theStmts)
Write the given statements to thewriter
static long
write(RDFWriter theWriter, java.lang.Iterable<Statement> theStmts, java.lang.Iterable<Namespace> theNamespaces)
Write the given statements and namespaces to thewriter
static long
write(java.io.OutputStream theStream, RDFFormat theFormat, java.lang.Iterable<Statement> theStmts)
Writes the statements similar towrite(RDFWriter, Iterable, Iterable)
.static long
write(java.io.OutputStream theStream, RDFFormat theFormat, java.lang.Iterable<Statement> theStmts, java.lang.Iterable<Namespace> theNamespaces)
Writes the statements similar towrite(RDFWriter, Iterable, Iterable)
.static long
writeGrouped(RDFWriter theWriter, java.lang.Iterable<Statement> theStmts, java.lang.Iterable<Namespace> theNamespaces)
Writes the statements similar towrite(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).static long
writeGrouped(java.io.OutputStream theStream, RDFFormat theFormat, java.lang.Iterable<Statement> theStmts, java.lang.Iterable<Namespace> theNamespaces)
Writes the statements similar towrite(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).
-
-
-
Method Detail
-
to
public static java.util.Optional<RDFWriter> to(@Nonnull java.io.OutputStream theOutput, @Nonnull RDFFormat theFormat)
- Parameters:
theOutput
- the output to write totheFormat
- the format to write in- Returns:
- the `RDFWriter` to use for writing
- See Also:
WriterOptions
- Implementation Notes:
- The `OutputStream` is *not* closed when writing is complete
-
to
public static java.util.Optional<RDFWriter> to(@Nonnull java.io.OutputStream theOutput, @Nonnull RDFFormat theFormat, @Nonnull java.lang.Iterable<Namespace> theNamespaces)
- Parameters:
theOutput
- the output to write totheFormat
- the format to write intheNamespaces
- the namespaces for writing- Returns:
- the `RDFWriter` to use for writing
- See Also:
WriterOptions
- Implementation Notes:
- The `OutputStream` is *not* closed when writing is complete
-
to
public static java.util.Optional<RDFWriter> to(@Nonnull java.io.OutputStream theOutput, @Nonnull RDFFormat theFormat, @Nonnull Options theWriterOptions)
- Parameters:
theOutput
- the output to write totheFormat
- the format to write intheWriterOptions
- the options for writing- Returns:
- the `RDFWriter` to use for writing
- See Also:
WriterOptions
- Implementation Notes:
- The `OutputStream` is *not* closed when writing is complete
-
write
public static long write(@Nonnull RDFWriter theWriter, @Nonnull java.lang.Iterable<Statement> theStmts)
Write the given statements to thewriter
-
write
public static long write(@Nonnull RDFWriter theWriter, @Nonnull java.lang.Iterable<Statement> theStmts, @Nonnull java.lang.Iterable<Namespace> theNamespaces)
Write the given statements and namespaces to thewriter
-
write
public static long write(@Nonnull java.io.OutputStream theStream, @Nonnull RDFFormat theFormat, @Nonnull java.lang.Iterable<Statement> theStmts)
Writes the statements similar towrite(RDFWriter, Iterable, Iterable)
.- Returns:
- the number of statements written (duplicate statements will be counted as many times as they appear)
- Throws:
java.lang.IllegalArgumentException
- if a writer supporting the given format is not found
-
write
public static long write(@Nonnull java.io.OutputStream theStream, @Nonnull RDFFormat theFormat, @Nonnull java.lang.Iterable<Statement> theStmts, @Nonnull java.lang.Iterable<Namespace> theNamespaces)
Writes the statements similar towrite(RDFWriter, Iterable, Iterable)
.- Returns:
- the number of statements written (duplicate statements will be counted as many times as they appear)
- Throws:
java.lang.IllegalArgumentException
- if a writer supporting the given format is not found
-
writeGrouped
public static long writeGrouped(@Nonnull java.io.OutputStream theStream, @Nonnull RDFFormat theFormat, @Nonnull java.lang.Iterable<Statement> theStmts, @Nonnull java.lang.Iterable<Namespace> theNamespaces)
Writes the statements similar towrite(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 java.lang.Iterable<Statement> theStmts, @Nonnull java.lang.Iterable<Namespace> theNamespaces)
Writes the statements similar towrite(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 java.lang.String toString(@Nonnull java.lang.Iterable<Statement> theStatements, @Nonnull RDFFormat theFormat)
Serialize the statements in the givenformat
as aString
.- Parameters:
theStatements
- the statements to serializetheFormat
- the RDF format to serialize into- Returns:
- the statements serialized in the given RDF format
- See Also:
RDFFormats
- 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 java.lang.String toString(@Nonnull java.lang.Iterable<Statement> theStatements, @Nonnull RDFFormat theFormat, @Nonnull java.lang.Iterable<Namespace> theNamespaces)
Serialize the statements in the givenformat
as aString
.- Parameters:
theStatements
- the statements to serializetheFormat
- the RDF format to serialize intotheNamespaces
- the namespaces to use for converting IRIs to QNames- Returns:
- the statements serialized in the given RDF format
- See Also:
RDFFormats
- 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(java.io.OutputStream theStream)
-
-