Class ParserConfig

java.lang.Object
org.eclipse.rdf4j.rio.RioConfig
org.eclipse.rdf4j.rio.ParserConfig
All Implemented Interfaces:
Serializable

public class ParserConfig extends RioConfig implements Serializable
A container object for easy setting and passing of RDFParser configuration options.
Author:
Jeen Broekstra, Peter Ansell
See Also:
Serialized Form
  • Constructor Details

    • ParserConfig

      public ParserConfig()
      Creates a ParserConfig object starting with default settings.
    • ParserConfig

      @Deprecated public ParserConfig(boolean verifyData, boolean stopAtFirstError, boolean preserveBNodeIDs, RDFParser.DatatypeHandling datatypeHandling)
      Deprecated.
      Use ParserConfig() instead and set preserveBNodeIDs using set(RioSetting, Object) with BasicParserSettings.PRESERVE_BNODE_IDS.

      The other parameters are all deprecated and this constructor may be removed in a future release.

      This constructor calls #setNonFatalErrors using a best-effort algorithm that may not match the exact semantics of the pre-2.7 constructor.

      Creates a ParserConfig object with the supplied config settings.
  • Method Details

    • setNonFatalErrors

      public ParserConfig setNonFatalErrors(Set<RioSetting<?>> nonFatalErrors)
      This method indicates a list of optional errors that the parser should attempt to recover from.

      If recovery is not possible, then the parser will still abort with an exception.

      Calls to this method will override previous calls, including the backwards-compatibility settings setup in the deprecated constructor.

      Non-Fatal errors that are detected MUST be reported to the error listener.

      Parameters:
      nonFatalErrors - The set of parser errors that are relevant to
      Returns:
      Either a copy of this config, if it is immutable, or this object, to allow chaining of method calls.
    • addNonFatalError

      public ParserConfig addNonFatalError(RioSetting<?> nextNonFatalError)
      Add a non-fatal error to the set used by parsers to determine whether they should attempt to recover from a particular parsing error.
      Parameters:
      nextNonFatalError - A non-fatal error that a parser should attempt to recover from.
      Returns:
      Either a copy of this config, if it is immutable, or this object, to allow chaining of method calls.
    • isNonFatalError

      public boolean isNonFatalError(RioSetting<?> errorToCheck)
      This method is used by the parser to check whether they should throw an exception or attempt to recover from a non-fatal error.

      If this method returns false, then the given non-fatal error will cause the parser to throw an exception.

      If this method returns true, then the parser will do its best to recover from the error, potentially by dropping triples or creating triples that do not exactly match the source.

      By default this method will always return false until setNonFatalErrors(Set) is called to specify the set of errors that are non-fatal in the given context.

      Non-Fatal errors that are detected MUST be reported to the error listener.

      Parameters:
      errorToCheck -
      Returns:
      True if the user has setup the parser configuration to indicate that this error is not necessarily fatal and false if the user has not indicated that this error is fatal.
    • getNonFatalErrors

      public Set<RioSetting<?>> getNonFatalErrors()
      Get the current set of non-fatal errors.
      Returns:
      An unmodifiable set containing the current non-fatal errors.
    • verifyData

      @Deprecated public boolean verifyData()
      Deprecated.
      All non-fatal verification errors must be specified using addNonFatalError(RioSetting) and checked using isNonFatalError(RioSetting).
    • stopAtFirstError

      @Deprecated public boolean stopAtFirstError()
      Deprecated.
      All non-fatal errors must be specified using setNonFatalErrors(Set) or addNonFatalError(RioSetting) and checked using isNonFatalError(RioSetting).
    • isPreserveBNodeIDs

      public boolean isPreserveBNodeIDs()
      This method is preserved for backwards compatibility.

      Code should be gradually migrated to use BasicParserSettings.PRESERVE_BNODE_IDS.

      Returns:
      Returns the BasicParserSettings.PRESERVE_BNODE_IDS setting.
    • datatypeHandling

      @Deprecated public RDFParser.DatatypeHandling datatypeHandling()
      Deprecated.
      Datatype handling is now split across BasicParserSettings.VERIFY_DATATYPE_VALUES, BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES and BasicParserSettings.NORMALIZE_DATATYPE_VALUES.

      This method will be removed in a future release.

    • useDefaults

      public ParserConfig useDefaults()
      Description copied from class: RioConfig
      Resets all settings back to their default values.
      Overrides:
      useDefaults in class RioConfig
      Returns:
      Either a copy of this config, if it is immutable, or this object, to allow chaining of method calls.
    • set

      public <T> ParserConfig set(RioSetting<T> setting, T value)
      Description copied from class: RioConfig
      Sets a RioSetting to have a new value. If the value is null, the parser setting is removed and the default will be used instead.
      Overrides:
      set in class RioConfig
      Parameters:
      setting - The setting to set a new value for.
      value - The value for the parser setting, or null to reset the parser setting to use the default value.
      Returns:
      Either a copy of this config, if it is immutable, or this object, to allow chaining of method calls.