Class ParserConfig
- All Implemented Interfaces:
Serializable
RDFParser
configuration options.- Author:
- Jeen Broekstra, Peter Ansell
- See Also:
-
Field Summary
Fields inherited from class org.eclipse.rdf4j.rio.RioConfig
log, settings, systemPropertyCache
-
Constructor Summary
ConstructorDescriptionCreates a ParserConfig object starting with default settings. -
Method Summary
Modifier and TypeMethodDescriptionaddNonFatalError
(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.Set<RioSetting<?>>
Get the current set of non-fatal errors.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.boolean
This method is preserved for backwards compatibility.<T> ParserConfig
set
(RioSetting<T> setting, T value) Sets aRioSetting
to have a new value.setNonFatalErrors
(Set<RioSetting<?>> nonFatalErrors) This method indicates a list of optional errors that the parser should attempt to recover from.Resets all settings back to their default values.
-
Constructor Details
-
ParserConfig
public ParserConfig()Creates a ParserConfig object starting with default settings.
-
-
Method Details
-
setNonFatalErrors
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
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
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
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
Description copied from class:RioConfig
Resets all settings back to their default values.- Overrides:
useDefaults
in classRioConfig
- Returns:
- Either a copy of this config, if it is immutable, or this object, to allow chaining of method calls.
-
set
Description copied from class:RioConfig
Sets aRioSetting
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 classRioConfig
- 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.
-