Overview
Concrete factory that creates format-specific result writers for serializing validation results to HTML, JUnit XML, or RDF formats.
Description
The RdfResultsWriterFactory provides static factory methods to create `RdfWriter` instances based on the requested `SerializationFormat`. For HTML output, it selects a writer subclass based on the test execution type (status, aggregate, SHACL Lite, SHACL). For JUnit XML, it similarly selects the appropriate XML writer. For all other RDF formats (Turtle, N3, RDF/XML, JSON-LD, etc.), it creates a generic `RdfFileWriter` or `RdfStreamWriter` that serializes the Jena model in the requested format.
Usage
- CLI result writing: Used by `ValidateCommand.call()` to create writers for all requested output formats.
- Multiple format output: Create one writer per format and wrap them in `RdfMultipleWriter` for simultaneous output.
Code Reference
Source Location
- Repository: AKSW/RDFUnit
- File: rdfunit-core/src/main/java/org/aksw/rdfunit/io/writer/RdfResultsWriterFactory.java
Signature
public final class RdfResultsWriterFactory {
public static RdfWriter createWriterFromFormat(
String filenameWithoutExtension,
SerializationFormat serializationFormat,
TestExecution testExecution);
public static RdfWriter createWriterFromFormat(
OutputStream outputStream,
SerializationFormat serializationFormat,
TestExecution testExecution);
public static AbstractRdfHtmlResultsWriter createHtmlWriter(
TestExecution testExecution, String filename);
public static AbstractJunitXmlResultsWriter createJunitXmlWriter(
TestExecution testExecution, String filename);
}
Import
import org.aksw.rdfunit.io.writer.RdfResultsWriterFactory;
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| filenameWithoutExtension |
String |
Yes |
Base filename; extension appended from format
|
| serializationFormat |
SerializationFormat |
Yes |
Output format (html, turtle, junitxml, etc.)
|
| testExecution |
TestExecution |
Yes |
Validation results to serialize
|
Outputs
| Name |
Type |
Description
|
| createWriterFromFormat() returns |
RdfWriter |
Writer that serializes results to file
|
Usage Examples
Create Writers for Multiple Formats
import org.aksw.rdfunit.io.writer.RdfResultsWriterFactory;
import org.aksw.rdfunit.io.writer.RdfMultipleWriter;
import org.aksw.rdfunit.io.format.FormatService;
import org.aksw.rdfunit.model.interfaces.results.TestExecution;
import java.util.ArrayList;
import java.util.List;
// Create writers for HTML and Turtle
List<RdfWriter> writers = new ArrayList<>();
writers.add(RdfResultsWriterFactory.createWriterFromFormat(
"results/output",
FormatService.getOutputFormat("html"),
testExecution));
writers.add(RdfResultsWriterFactory.createWriterFromFormat(
"results/output",
FormatService.getOutputFormat("turtle"),
testExecution));
// Write all formats at once
RdfMultipleWriter multiWriter = new RdfMultipleWriter(writers);
multiWriter.write(resultModel);
Write to OutputStream
// Write JUnit XML to stdout
RdfWriter xmlWriter = RdfResultsWriterFactory.createWriterFromFormat(
System.out,
FormatService.getOutputFormat("junitxml"),
testExecution);
xmlWriter.write(resultModel);
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.