Package org.eclipse.rdf4j.rio

## Interface RDFParser

- All Known Implementing Classes:
    `AbstractRDFParser`, `BinaryRDFParser`, `HDTParser`, `JSONLDParser`, `N3Parser`, `NDJSONLDParser`, `NQuadsParser`, `NTriplesParser`, `RDFJSONParser`, `RDFXMLParser`, `SPARQLUpdateDataBlockParser`, `SPARQLUpdateDataBlockParser`, `TriGParser`, `TriGStarParser`, `TriXParser`, `TurtleParser`, `TurtleStarParser`, `XMLReaderBasedParser`

      public interface RDFParser

  An interface for RDF parsers. All implementing classes should define a public zero-argument constructor to allow them to be created through reflection.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ParserConfig` | `getParserConfig()` | Retrieves the current parser configuration as a single object.
    `RDFFormat` | `getRDFFormat()` | Gets the RDF format that this parser can parse.
    `Collection<RioSetting<?>>` | `getSupportedSettings()` |
    `default void` | `parse​(InputStream in)` | Parses the data from the supplied InputStream.
    `void` | `parse​(InputStream in, String baseURI)` | Parses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI references.
    `default void` | `parse​(Reader reader)` | Parses the data from the supplied Reader.
    `void` | `parse​(Reader reader, String baseURI)` | Parses the data from the supplied Reader, using the supplied baseURI to resolve any relative URI references.
    `<T> RDFParser` | `set​(RioSetting<T> setting, T value)` | Set a setting on the parser, and return this parser object to allow chaining.
    `RDFParser` | `setParseErrorListener​(ParseErrorListener el)` | Sets the ParseErrorListener that will be notified of any errors that this parser finds during parsing.
    `RDFParser` | `setParseLocationListener​(ParseLocationListener ll)` | Sets the ParseLocationListener that will be notified of the parser's progress during the parse process.
    `RDFParser` | `setParserConfig​(ParserConfig config)` | Sets all supplied parser configuration options.
    `void` | `setPreserveBNodeIDs​(boolean preserveBNodeIDs)` | Set whether the parser should preserve bnode identifiers specified in the source (default is false).
    `RDFParser` | `setRDFHandler​(RDFHandler handler)` | Sets the RDFHandler that will handle the parsed RDF data.
    `RDFParser` | `setValueFactory​(ValueFactory valueFactory)` | Sets the ValueFactory that the parser will use to create Value objects for the parsed RDF data.

- - ### Method Detail

    - #### getRDFFormat

          RDFFormat getRDFFormat()

      Gets the RDF format that this parser can parse.

    - #### setValueFactory

          RDFParser setValueFactory​(ValueFactory valueFactory)

      Sets the ValueFactory that the parser will use to create Value objects for the parsed RDF data.
      Parameters:
        `valueFactory` - The value factory that the parser should use.
      Returns:
        Either a copy of this parser, if it is immutable, or this object, to allow chaining of method calls.

    - #### setRDFHandler

          RDFParser setRDFHandler​(RDFHandler handler)

      Sets the RDFHandler that will handle the parsed RDF data.
      Parameters:
        `handler` - The RDFHandler to handle the parsed data.
      Returns:
        Either a copy of this parser, if it is immutable, or this object, to allow chaining of method calls.

    - #### setParseErrorListener

          RDFParser setParseErrorListener​(ParseErrorListener el)

      Sets the ParseErrorListener that will be notified of any errors that this parser finds during parsing.
      Parameters:
        `el` - The ParseErrorListener that will be notified of errors or warnings.
      Returns:
        Either a copy of this parser, if it is immutable, or this object, to allow chaining of method calls.

    - #### setParseLocationListener

          RDFParser setParseLocationListener​(ParseLocationListener ll)

      Sets the ParseLocationListener that will be notified of the parser's progress during the parse process.
      Parameters:
        `ll` - The ParseLocationListener that will be notified of the parser's progress.
      Returns:
        Either a copy of this parser, if it is immutable, or this object, to allow chaining of method calls.

    - #### setParserConfig

          RDFParser setParserConfig​(ParserConfig config)

      Sets all supplied parser configuration options.
      Parameters:
        `config` - a parser configuration object.
      Returns:
        Either a copy of this parser, if it is immutable, or this object, to allow chaining of method calls.

    - #### getParserConfig

          ParserConfig getParserConfig()

      Retrieves the current parser configuration as a single object.
      Returns:
        a parser configuration object representing the current configuration of the parser.

    - #### getSupportedSettings

          Collection<RioSetting<?>> getSupportedSettings()

      Returns:
        A collection of `RioSetting`s that are supported by this RDFParser.

    - #### set

          <T> RDFParser set​(RioSetting<T> setting,
                            T value)

      Set a setting on the parser, and return this parser object to allow chaining.
      Parameters:
        `setting` - The setting to change.
        `value` - The value to change.
      Returns:
        Either a copy of this parser, if it is immutable, or this object, to allow chaining of method calls.

    - #### setPreserveBNodeIDs

          void setPreserveBNodeIDs​(boolean preserveBNodeIDs)

      Set whether the parser should preserve bnode identifiers specified in the source (default is false).

    - #### parse

          default void parse​(InputStream in)
                      throws IOException,
                             RDFParseException,
                             RDFHandlerException

      Parses the data from the supplied InputStream.
      Parameters:
        `in` - The InputStream from which to read the data.
      Throws:
        `IOException` - If an I/O error occurred while data was read from the InputStream.
        `RDFParseException` - If the parser has found an unrecoverable parse error.
        `RDFHandlerException` - If the configured statement handler has encountered an unrecoverable error.
      Since:
        3.5.0

    - #### parse

          void parse​(InputStream in,
                     String baseURI)
              throws IOException,
                     RDFParseException,
                     RDFHandlerException

      Parses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI references.
      Parameters:
        `in` - The InputStream from which to read the data.
        `baseURI` - The URI associated with the data in the InputStream. May be `null`. Parsers for syntax formats that do not support relative URIs will ignore this argument.

        Note that if the data contains an embedded base URI, that embedded base URI will overrule the value supplied here (see RFC 3986 section 5.1 for details).

      Throws:
        `IOException` - If an I/O error occurred while data was read from the InputStream.
        `RDFParseException` - If the parser has found an unrecoverable parse error.
        `RDFHandlerException` - If the configured statement handler has encountered an unrecoverable error.

    - #### parse

          default void parse​(Reader reader)
                      throws IOException,
                             RDFParseException,
                             RDFHandlerException

      Parses the data from the supplied Reader.
      Parameters:
        `reader` - The Reader from which to read the data.
      Throws:
        `IOException` - If an I/O error occurred while data was read from the InputStream.
        `RDFParseException` - If the parser has found an unrecoverable parse error.
        `RDFHandlerException` - If the configured statement handler has encountered an unrecoverable error.
      Since:
        3.5.0

    - #### parse

          void parse​(Reader reader,
                     String baseURI)
              throws IOException,
                     RDFParseException,
                     RDFHandlerException

      Parses the data from the supplied Reader, using the supplied baseURI to resolve any relative URI references.
      Parameters:
        `reader` - The Reader from which to read the data.
        `baseURI` - The URI associated with the data in the InputStream. May be `null`. Parsers for syntax formats that do not support relative URIs will ignore this argument.

        Note that if the data contains an embedded base URI, that embedded base URI will overrule the value supplied here (see RFC 3986 section 5.1 for details).

      Throws:
        `IOException` - If an I/O error occurred while data was read from the InputStream.
        `RDFParseException` - If the parser has found an unrecoverable parse error.
        `RDFHandlerException` - If the configured statement handler has encountered an unrecoverable error.