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 ofRDFParser
configuration options.- Author:
- Jeen Broekstra, Peter Ansell
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.eclipse.rdf4j.rio.RioConfig
log, settings, systemPropertyCache
-
-
Constructor Summary
Constructors Constructor Description ParserConfig()
Creates a ParserConfig object starting with default settings.ParserConfig(boolean verifyData, boolean stopAtFirstError, boolean preserveBNodeIDs, RDFParser.DatatypeHandling datatypeHandling)
Deprecated.UseParserConfig()
instead and set preserveBNodeIDs usingset(RioSetting, Object)
withBasicParserSettings.PRESERVE_BNODE_IDS
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.RDFParser.DatatypeHandling
datatypeHandling()
Deprecated.Datatype handling is now split acrossBasicParserSettings.VERIFY_DATATYPE_VALUES
,BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES
andBasicParserSettings.NORMALIZE_DATATYPE_VALUES
.Set<RioSetting<?>>
getNonFatalErrors()
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
isPreserveBNodeIDs()
This method is preserved for backwards compatibility.<T> ParserConfig
set(RioSetting<T> setting, T value)
Sets aRioSetting
to have a new value.ParserConfig
setNonFatalErrors(Set<RioSetting<?>> nonFatalErrors)
This method indicates a list of optional errors that the parser should attempt to recover from.boolean
stopAtFirstError()
Deprecated.All non-fatal errors must be specified usingsetNonFatalErrors(Set)
oraddNonFatalError(RioSetting)
and checked usingisNonFatalError(RioSetting)
.ParserConfig
useDefaults()
Resets all settings back to their default values.boolean
verifyData()
Deprecated.All non-fatal verification errors must be specified usingaddNonFatalError(RioSetting)
and checked usingisNonFatalError(RioSetting)
.
-
-
-
Constructor Detail
-
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.UseParserConfig()
instead and set preserveBNodeIDs usingset(RioSetting, Object)
withBasicParserSettings.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 Detail
-
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 usingaddNonFatalError(RioSetting)
and checked usingisNonFatalError(RioSetting)
.
-
stopAtFirstError
@Deprecated public boolean stopAtFirstError()
Deprecated.All non-fatal errors must be specified usingsetNonFatalErrors(Set)
oraddNonFatalError(RioSetting)
and checked usingisNonFatalError(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 acrossBasicParserSettings.VERIFY_DATATYPE_VALUES
,BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES
andBasicParserSettings.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 classRioConfig
- 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 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.
-
-