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:
  • Constructor Details

    • ParserConfig

      public ParserConfig()
      Creates a ParserConfig object starting with default 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.
    • 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.
    • 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.