Class RDFJSONParser

java.lang.Object
org.eclipse.rdf4j.rio.helpers.AbstractRDFParser
org.eclipse.rdf4j.rio.rdfjson.RDFJSONParser
All Implemented Interfaces:
RDFParser

public class RDFJSONParser extends AbstractRDFParser implements RDFParser
RDFParser implementation for the RDF/JSON format
Author:
Peter Ansell
  • Constructor Details

    • RDFJSONParser

      public RDFJSONParser()
      Creates a parser using RDFFormat.RDFJSON to identify the parser.
    • RDFJSONParser

      public RDFJSONParser(RDFFormat actualFormat)
      Creates a parser using the given RDFFormat to self identify.
      Parameters:
      actualFormat -
  • Method Details

    • getRDFFormat

      public RDFFormat getRDFFormat()
      Description copied from interface: RDFParser
      Gets the RDF format that this parser can parse.
      Specified by:
      getRDFFormat in interface RDFParser
    • parse

      public void parse(InputStream inputStream, String baseUri) throws IOException, RDFParseException, RDFHandlerException
      Description copied from interface: RDFParser
      Parses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI references.
      Specified by:
      parse in interface RDFParser
      Parameters:
      inputStream - 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.
    • createLiteral

      protected Literal createLiteral(String label, String language, IRI datatype, com.fasterxml.jackson.core.JsonLocation currentLocation) throws RDFParseException
      Creates a literal, using the current value, language, and datatype, and additionally using the given JsonLocation to provide information about the line and column numbers in the event of a warning, error or exception being generated by the creation of the literal.
      Parameters:
      label - the literal's lexical label
      language - the literal's language tag. Can be null.
      datatype - the literal's datatype. Can be null.
      currentLocation - the current JsonLocation. May not be null.
      Returns:
      the created Literal object.
      Throws:
      RDFParseException
    • reportError

      protected void reportError(String msg, Exception e, com.fasterxml.jackson.core.JsonLocation location, RioSetting<Boolean> setting) throws RDFParseException
      Throws:
      RDFParseException
    • reportError

      protected void reportError(String msg, com.fasterxml.jackson.core.JsonLocation location, RioSetting<Boolean> setting) throws RDFParseException
      Throws:
      RDFParseException
    • reportFatalError

      protected void reportFatalError(String msg, Exception e, com.fasterxml.jackson.core.JsonLocation location) throws RDFParseException
      Throws:
      RDFParseException
    • reportFatalError

      protected void reportFatalError(String msg, com.fasterxml.jackson.core.JsonLocation location) throws RDFParseException
      Throws:
      RDFParseException
    • parse

      public void parse(Reader reader, String baseUri) throws IOException, RDFParseException, RDFHandlerException
      Description copied from interface: RDFParser
      Parses the data from the supplied Reader, using the supplied baseURI to resolve any relative URI references.
      Specified by:
      parse in interface RDFParser
      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.
    • getSupportedSettings

      public Collection<RioSetting<?>> getSupportedSettings()
      Specified by:
      getSupportedSettings in interface RDFParser
      Overrides:
      getSupportedSettings in class AbstractRDFParser
      Returns:
      A collection of RioSettings that are supported by this RDFParser.