Package org.eclipse.rdf4j.rio.trig
Class TriGWriter
- java.lang.Object
-
- org.eclipse.rdf4j.rio.helpers.AbstractRDFWriter
-
- org.eclipse.rdf4j.rio.turtle.TurtleWriter
-
- org.eclipse.rdf4j.rio.trig.TriGWriter
-
- All Implemented Interfaces:
CharSink
,Sink
,RDFHandler
,RDFWriter
- Direct Known Subclasses:
TriGStarWriter
public class TriGWriter extends TurtleWriter
An extension ofTurtleWriter
that writes RDF documents in TriG format by adding graph scopes to the Turtle document.
-
-
Field Summary
Fields Modifier and Type Field Description private Resource
currentContext
private boolean
inActiveContext
-
Fields inherited from class org.eclipse.rdf4j.rio.turtle.TurtleWriter
baseIRI, bufferedStatements, lastWrittenPredicate, lastWrittenSubject, statementClosed, writer
-
Fields inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFWriter
namespaceTable, statementConsumer
-
-
Constructor Summary
Constructors Constructor Description TriGWriter(java.io.OutputStream out)
Creates a new TriGWriter that will write to the supplied OutputStream.TriGWriter(java.io.OutputStream out, ParsedIRI baseIRI)
Creates a new TriGWriter that will write to the supplied OutputStream.TriGWriter(java.io.Writer writer)
Creates a new TriGWriter that will write to the supplied Writer.TriGWriter(java.io.Writer writer, ParsedIRI baseIRI)
Creates a new TriGWriter that will write to the supplied Writer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeActiveContext()
private static boolean
contextsEquals(Resource context1, Resource context2)
void
endRDF()
Signals the end of the RDF data.RDFFormat
getRDFFormat()
Gets the RDF format that this RDFWriter uses.void
startRDF()
Signals the start of the RDF data.protected void
writeNamespace(java.lang.String prefix, java.lang.String name)
protected void
writeStatement(Resource subj, IRI pred, Value obj, Resource context, boolean canShortenSubject, boolean canShortenObject)
-
Methods inherited from class org.eclipse.rdf4j.rio.turtle.TurtleWriter
closePreviousStatement, consumeStatement, getModelFactory, getSupportedSettings, getWriter, handleComment, handleNamespace, handleStatementInternal, setModelFactory, writeBase, writeBNode, writeBNode, writeCommentLine, writeLiteral, writePredicate, writeResource, writeResource, writeTriple, writeTripleRDFStar, writeURI, writeValue, writeValue
-
Methods inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFWriter
checkWritingStarted, getFileFormat, getWriterConfig, handleStatement, isWritingStarted, set, setWriterConfig
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.common.io.Sink
acceptsFileFormat, getFileFormat
-
-
-
-
Field Detail
-
inActiveContext
private boolean inActiveContext
-
currentContext
private Resource currentContext
-
-
Constructor Detail
-
TriGWriter
public TriGWriter(java.io.OutputStream out)
Creates a new TriGWriter that will write to the supplied OutputStream.- Parameters:
out
- The OutputStream to write the TriG document to.
-
TriGWriter
public TriGWriter(java.io.OutputStream out, ParsedIRI baseIRI)
Creates a new TriGWriter that will write to the supplied OutputStream.- Parameters:
out
- The OutputStream to write the TriG document to.baseIRI
-
-
TriGWriter
public TriGWriter(java.io.Writer writer)
Creates a new TriGWriter that will write to the supplied Writer.- Parameters:
writer
- The Writer to write the TriG document to.
-
TriGWriter
public TriGWriter(java.io.Writer writer, ParsedIRI baseIRI)
Creates a new TriGWriter that will write to the supplied Writer.- Parameters:
writer
- The Writer to write the TriG document to.baseIRI
-
-
-
Method Detail
-
getRDFFormat
public RDFFormat getRDFFormat()
Description copied from interface:RDFWriter
Gets the RDF format that this RDFWriter uses.- Specified by:
getRDFFormat
in interfaceRDFWriter
- Overrides:
getRDFFormat
in classTurtleWriter
-
startRDF
public void startRDF() throws RDFHandlerException
Description copied from interface:RDFHandler
Signals the start of the RDF data. This method is called before any data is reported.- Specified by:
startRDF
in interfaceRDFHandler
- Overrides:
startRDF
in classTurtleWriter
- Throws:
RDFHandlerException
- If the RDF handler has encountered an unrecoverable error.
-
endRDF
public void endRDF() throws RDFHandlerException
Description copied from interface:RDFHandler
Signals the end of the RDF data. This method is called when all data has been reported.- Specified by:
endRDF
in interfaceRDFHandler
- Overrides:
endRDF
in classTurtleWriter
- Throws:
RDFHandlerException
- If the RDF handler has encountered an unrecoverable error.
-
writeStatement
protected void writeStatement(Resource subj, IRI pred, Value obj, Resource context, boolean canShortenSubject, boolean canShortenObject) throws java.io.IOException
- Overrides:
writeStatement
in classTurtleWriter
- Throws:
java.io.IOException
-
writeNamespace
protected void writeNamespace(java.lang.String prefix, java.lang.String name) throws java.io.IOException
- Overrides:
writeNamespace
in classTurtleWriter
- Throws:
java.io.IOException
-
closeActiveContext
protected void closeActiveContext() throws java.io.IOException
- Throws:
java.io.IOException
-
-