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:
    RDFHandler, RDFWriter

      public class TriGWriter
      extends TurtleWriter

  An extension of `TurtleWriter` that writes RDF documents in TriG format by adding graph scopes to the Turtle document.
  Author:
    Arjohn Kampman

- - ### Field Summary

    - ### Fields inherited from class org.eclipse.rdf4j.rio.turtle.TurtleWriter

      `baseIRI, lastWrittenPredicate, lastWrittenSubject, prettyPrintModel, statementClosed, writer, writingStarted`

    - ### Fields inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFWriter

      `namespaceTable`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TriGWriter(OutputStream out)` Creates a new TriGWriter that will write to the supplied OutputStream.
    `TriGWriter(OutputStream out, ParsedIRI baseIRI)` Creates a new TriGWriter that will write to the supplied OutputStream.
    `TriGWriter(Writer writer)` Creates a new TriGWriter that will write to the supplied Writer.
    `TriGWriter(Writer writer, ParsedIRI baseIRI)` Creates a new TriGWriter that will write to the supplied Writer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `closeActiveContext()`
    `void` | `endRDF()` Signals the end of the RDF data.
    `RDFFormat` | `getRDFFormat()` Gets the RDF format that this RDFWriter uses.
    `void` | `handleStatement(Statement st)` Handles a statement.
    `protected void` | `handleStatementInternal(Statement st, boolean endRDFCalled, boolean canShortenSubject, boolean canShortenObject)` Internal method that differentiates between the pretty-print and streaming writer cases.
    `void` | `startRDF()` Signals the start of the RDF data.
    `protected void` | `writeCommentLine(String line)`
    `protected void` | `writeNamespace(String prefix, String name)`

    - ### Methods inherited from class org.eclipse.rdf4j.rio.turtle.TurtleWriter

      `closePreviousStatement, handleComment, handleNamespace, writeBase, writeBNode, writeBNode, writeLiteral, writePredicate, writeResource, writeResource, writeURI, writeValue, writeValue`

    - ### Methods inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFWriter

      `getSupportedSettings, getWriterConfig, 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.rio.RDFWriter

      `getSupportedSettings, getWriterConfig, set, setWriterConfig`

- - ### Constructor Detail

    - #### TriGWriter

          public TriGWriter(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(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.

    - #### TriGWriter

          public TriGWriter(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(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.

  - ### Method Detail

    - #### getRDFFormat

          public RDFFormat getRDFFormat()

      Description copied from interface: `RDFWriter`
      Gets the RDF format that this RDFWriter uses.
      Specified by:
        `getRDFFormat` in interface `RDFWriter`
      Overrides:
        `getRDFFormat` in class `TurtleWriter`

    - #### 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 interface `RDFHandler`
      Overrides:
        `startRDF` in class `TurtleWriter`
      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 interface `RDFHandler`
      Overrides:
        `endRDF` in class `TurtleWriter`
      Throws:
        `RDFHandlerException` - If the RDF handler has encountered an unrecoverable error.

    - #### handleStatement

          public void handleStatement(Statement st)
                               throws RDFHandlerException

      Description copied from interface: `RDFHandler`
      Handles a statement.
      Specified by:
        `handleStatement` in interface `RDFHandler`
      Overrides:
        `handleStatement` in class `TurtleWriter`
      Parameters:
        `st` - The statement.
      Throws:
        `RDFHandlerException` - If the RDF handler has encountered an unrecoverable error.

    - #### handleStatementInternal

          protected void handleStatementInternal(Statement st,
                                                 boolean endRDFCalled,
                                                 boolean canShortenSubject,
                                                 boolean canShortenObject)

      Description copied from class: `TurtleWriter`
      Internal method that differentiates between the pretty-print and streaming writer cases.
      Overrides:
        `handleStatementInternal` in class `TurtleWriter`
      Parameters:
        `st` - The next statement to write
        `endRDFCalled` - True if endRDF has been called before this method is called. This is used to buffer statements for pretty-printing before dumping them when all statements have been delivered to us.
        `canShortenSubject` - True if, in the current context, we may be able to shorten the subject of this statement iff it is an instance of `BNode`.
        `canShortenObject` - True if, in the current context, we may be able to shorten the object of this statement iff it is an instance of `BNode`.

    - #### writeCommentLine

          protected void writeCommentLine(String line)
                                   throws IOException

      Overrides:
        `writeCommentLine` in class `TurtleWriter`
      Throws:
        `IOException`

    - #### writeNamespace

          protected void writeNamespace(String prefix,
                                        String name)
                                 throws IOException

      Overrides:
        `writeNamespace` in class `TurtleWriter`
      Throws:
        `IOException`

    - #### closeActiveContext

          protected void closeActiveContext()
                                     throws IOException

      Throws:
        `IOException`

Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.