Package com.stardog.stark.io.turtle
Class PrettyTurtleWriter
- java.lang.Object
-
- com.stardog.stark.io.turtle.TurtleWriter
-
- com.stardog.stark.io.turtle.PrettyTurtleWriter
-
- All Implemented Interfaces:
RDFHandler
,RDFWriter
public class PrettyTurtleWriter extends TurtleWriter implements RDFWriter
An Turtle
writer
that abbreviates bnodes and lists. This writer requires to buffer all the triples in memory before writing so no output will be printed untilend()
is called. If the number of triples exceed a limit, the writer prints them asTurtleWriter
, i.e. without bnode and list shortcuts.- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
- Implementation Notes:
- Comments are not supported with this writer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PrettyTurtleWriter.PrettyTurtleWriterFactory
-
Nested classes/interfaces inherited from class com.stardog.stark.io.turtle.TurtleWriter
TurtleWriter.TurtleWriterFactory
-
-
Field Summary
-
Fields inherited from class com.stardog.stark.io.turtle.TurtleWriter
mBlockSpec, mLastWrittenPredicate, mLastWrittenSubject, mNamespaces, mOptions, mStarted, mStmtClosed, mWriter
-
-
Constructor Summary
Constructors Constructor Description PrettyTurtleWriter(java.io.OutputStream theWriter, Options theOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
comment(java.lang.String theComment)
Write a comment to the output.void
end()
Signals the writing process is completed.RDFFormat
format()
Theformat
this writer will serialize output in.void
handle(Statement theStmt)
Write the givenStatement
void
namespace(java.lang.String thePrefix, java.lang.String theIRI)
Provide a namespace to the writer.void
start()
Signals that the RDF writing process is starting.-
Methods inherited from class com.stardog.stark.io.turtle.TurtleWriter
closePreviousStatement, writeBNode, writeCommentLine, writeEmbeddedTriple, writeIRI, writeLiteral, writeNamespace, writePredicate, writeResource, writeValue
-
-
-
-
Constructor Detail
-
PrettyTurtleWriter
public PrettyTurtleWriter(java.io.OutputStream theWriter, Options theOptions)
-
-
Method Detail
-
start
public void start()
Signals that the RDF writing process is starting.- Specified by:
start
in interfaceRDFHandler
- Specified by:
start
in interfaceRDFWriter
- Overrides:
start
in classTurtleWriter
-
handle
public void handle(@Nonnull Statement theStmt)
Write the givenStatement
- Specified by:
handle
in interfaceRDFHandler
- Specified by:
handle
in interfaceRDFWriter
- Overrides:
handle
in classTurtleWriter
- Parameters:
theStmt
- the statement to write
-
end
public void end()
Signals the writing process is completed. The underlyingInputStream
is *not* closed, but the caller should not call additional methods on this writer as that will normally yield syntax errors in the output.- Specified by:
end
in interfaceRDFHandler
- Specified by:
end
in interfaceRDFWriter
- Overrides:
end
in classTurtleWriter
-
comment
public void comment(@Nonnull java.lang.String theComment)
Write a comment to the output. Writing need not bestarted
at this point; comments can be written prior to any actual serialized RDF- Specified by:
comment
in interfaceRDFWriter
- Overrides:
comment
in classTurtleWriter
- Parameters:
theComment
- the comment to write
-
namespace
public void namespace(@Nonnull java.lang.String thePrefix, @Nonnull java.lang.String theIRI)
Description copied from class:TurtleWriter
Provide a namespace to the writer. This method can be called before writing hasstarted
, in which case, the namespace bindings are buffered and written when appropriate after writing has begun.- Specified by:
namespace
in interfaceRDFHandler
- Specified by:
namespace
in interfaceRDFWriter
- Overrides:
namespace
in classTurtleWriter
- Parameters:
thePrefix
- the namespace prefixtheIRI
- the associated IRI
-
-