public abstract class AbstractRDFParser extends Object implements RDFParser
RDFParser
s offering common functionality for RDF parsers.RDFParser.DatatypeHandling
Modifier and Type | Field and Description |
---|---|
protected RDFHandler |
rdfHandler
The RDFHandler that will handle the parsed RDF.
|
protected ValueFactory |
valueFactory
The ValueFactory to use for creating RDF model objects.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractRDFParser()
Creates a new RDFParserBase that will use a
SimpleValueFactory to create RDF model objects. |
protected |
AbstractRDFParser(ValueFactory valueFactory)
Creates a new RDFParserBase that will use the supplied ValueFactory to create RDF model objects.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clear()
Clears any information that has been collected while parsing.
|
protected void |
clearBNodeIDMap()
Deprecated.
Map is no longer used, call
clear() instead. |
protected BNode |
createBNode()
Deprecated.
|
protected BNode |
createBNode(String nodeID)
Deprecated.
|
protected Literal |
createLiteral(String label,
String lang,
IRI datatype)
Creates a
Literal object with the supplied parameters. |
protected Literal |
createLiteral(String label,
String lang,
IRI datatype,
long lineNo,
long columnNo)
Creates a
Literal object with the supplied parameters, using the lineNo and columnNo to enhance error
messages or exceptions that may be generated during the creation of the literal. |
protected Resource |
createNode()
|
protected Resource |
createNode(String nodeID)
|
protected Statement |
createStatement(Resource subj,
IRI pred,
Value obj)
Creates a new
Statement object with the supplied components. |
protected Statement |
createStatement(Resource subj,
IRI pred,
Value obj,
Resource context)
Creates a new
Statement object with the supplied components. |
protected IRI |
createURI(String uri)
Creates a
IRI object for the specified URI-string. |
RDFParser.DatatypeHandling |
datatypeHandling()
Deprecated.
|
protected String |
getNamespace(String prefix)
Gets the namespace that is associated with the specified prefix or throws an
RDFParseException . |
ParseErrorListener |
getParseErrorListener() |
ParseLocationListener |
getParseLocationListener() |
ParserConfig |
getParserConfig()
Retrieves the current parser configuration as a single object.
|
RDFHandler |
getRDFHandler() |
Collection<RioSetting<?>> |
getSupportedSettings() |
protected void |
initializeNamespaceTableFromConfiguration() |
boolean |
preserveBNodeIDs() |
protected void |
reportError(Exception e,
long lineNo,
long columnNo,
RioSetting<Boolean> relevantSetting)
Reports an error with associated line- and column number to the registered ParseErrorListener, if the given
setting has been set to true.
|
protected void |
reportError(Exception e,
RioSetting<Boolean> relevantSetting)
Reports an error with associated line- and column number to the registered ParseErrorListener, if the given
setting has been set to true.
|
protected void |
reportError(String msg,
Exception e,
long lineNo,
long columnNo,
RioSetting<Boolean> relevantSetting)
Reports an error with associated line- and column number to the registered ParseErrorListener, if the given
setting has been set to true.
|
protected void |
reportError(String msg,
long lineNo,
long columnNo,
RioSetting<Boolean> relevantSetting)
Reports an error with associated line- and column number to the registered ParseErrorListener, if the given
setting has been set to true.
|
protected void |
reportError(String msg,
RioSetting<Boolean> relevantSetting)
Reports an error with associated line- and column number to the registered ParseErrorListener, if the given
setting has been set to true.
|
protected void |
reportFatalError(Exception e)
Reports a fatal error to the registered ParseErrorListener, if any, and throws a ParseException
afterwards.
|
protected void |
reportFatalError(Exception e,
long lineNo,
long columnNo)
Reports a fatal error with associated line- and column number to the registered ParseErrorListener, if any, and
throws a ParseException wrapped the supplied exception afterwards.
|
protected void |
reportFatalError(String msg)
Reports a fatal error to the registered ParseErrorListener, if any, and throws a ParseException
afterwards.
|
protected void |
reportFatalError(String message,
Exception e,
long lineNo,
long columnNo)
Reports a fatal error with associated line- and column number to the registered ParseErrorListener, if any, and
throws a ParseException wrapped the supplied exception afterwards.
|
protected void |
reportFatalError(String msg,
long lineNo,
long columnNo)
Reports a fatal error with associated line- and column number to the registered ParseErrorListener, if any, and
throws a ParseException afterwards.
|
protected void |
reportLocation(long lineNo,
long columnNo)
Reports the specified line- and column number to the registered
ParseLocationListener , if any. |
protected void |
reportWarning(String msg)
Reports a warning to the registered ParseErrorListener, if any.
|
protected void |
reportWarning(String msg,
long lineNo,
long columnNo)
Reports a warning with associated line- and column number to the registered ParseErrorListener, if any.
|
protected IRI |
resolveURI(String uriSpec)
Resolves a URI-string against the base URI and creates a
IRI object for it. |
<T> RDFParser |
set(RioSetting<T> setting,
T value)
Set a setting on the parser, and return this parser object to allow chaining.
|
protected void |
setBaseURI(ParsedIRI baseURI)
Sets the base URI for resolving relative URIs.
|
protected void |
setBaseURI(String uriSpec)
Parses the supplied URI-string and sets it as the base URI for resolving relative URIs.
|
void |
setDatatypeHandling(RDFParser.DatatypeHandling datatypeHandling)
Sets the datatype handling mode.
|
protected void |
setNamespace(String prefix,
String namespace)
Associates the specified prefix to the specified namespace.
|
RDFParser |
setParseErrorListener(ParseErrorListener el)
Sets the ParseErrorListener that will be notified of any errors that this parser finds during parsing.
|
RDFParser |
setParseLocationListener(ParseLocationListener el)
Sets the ParseLocationListener that will be notified of the parser's progress during the parse process.
|
RDFParser |
setParserConfig(ParserConfig config)
Sets all supplied parser configuration options.
|
void |
setPreserveBNodeIDs(boolean preserveBNodeIDs)
Set whether the parser should preserve bnode identifiers specified in the source (default is false).
|
RDFParser |
setRDFHandler(RDFHandler handler)
Sets the RDFHandler that will handle the parsed RDF data.
|
void |
setStopAtFirstError(boolean stopAtFirstError)
Deprecated.
|
RDFParser |
setValueFactory(ValueFactory valueFactory)
Sets the ValueFactory that the parser will use to create Value objects for the parsed RDF data.
|
void |
setVerifyData(boolean verifyData)
Sets whether the parser should verify the data it parses (default value is true).
|
boolean |
stopAtFirstError()
Deprecated.
Check specific settings instead.
|
boolean |
verifyData()
Deprecated.
Use specific settings instead.
|
protected RDFHandler rdfHandler
protected ValueFactory valueFactory
protected AbstractRDFParser()
SimpleValueFactory
to create RDF model objects.protected AbstractRDFParser(ValueFactory valueFactory)
valueFactory
- A ValueFactory.public RDFParser setValueFactory(ValueFactory valueFactory)
RDFParser
setValueFactory
in interface RDFParser
valueFactory
- The value factory that the parser should use.public RDFParser setRDFHandler(RDFHandler handler)
RDFParser
setRDFHandler
in interface RDFParser
handler
- The RDFHandler to handle the parsed data.public RDFHandler getRDFHandler()
public RDFParser setParseErrorListener(ParseErrorListener el)
RDFParser
setParseErrorListener
in interface RDFParser
el
- The ParseErrorListener that will be notified of errors or warnings.public ParseErrorListener getParseErrorListener()
public RDFParser setParseLocationListener(ParseLocationListener el)
RDFParser
setParseLocationListener
in interface RDFParser
el
- The ParseLocationListener that will be notified of the parser's progress.public ParseLocationListener getParseLocationListener()
public RDFParser setParserConfig(ParserConfig config)
RDFParser
setParserConfig
in interface RDFParser
config
- a parser configuration object.public ParserConfig getParserConfig()
RDFParser
getParserConfig
in interface RDFParser
public Collection<RioSetting<?>> getSupportedSettings()
getSupportedSettings
in interface RDFParser
RioSetting
s that are supported by this RDFParser.public <T> RDFParser set(RioSetting<T> setting, T value)
RDFParser
public void setVerifyData(boolean verifyData)
RDFParser
setVerifyData
in interface RDFParser
@Deprecated public boolean verifyData()
public void setPreserveBNodeIDs(boolean preserveBNodeIDs)
RDFParser
setPreserveBNodeIDs
in interface RDFParser
public boolean preserveBNodeIDs()
@Deprecated public void setStopAtFirstError(boolean stopAtFirstError)
RDFParser
setStopAtFirstError
in interface RDFParser
@Deprecated public boolean stopAtFirstError()
public void setDatatypeHandling(RDFParser.DatatypeHandling datatypeHandling)
RDFParser
setDatatypeHandling
in interface RDFParser
datatypeHandling
- A datatype handling option.@Deprecated public RDFParser.DatatypeHandling datatypeHandling()
BasicParserSettings.VERIFY_DATATYPE_VALUES
and
BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES
and
BasicParserSettings.NORMALIZE_DATATYPE_VALUES
instead.protected void setBaseURI(String uriSpec)
protected void setBaseURI(ParsedIRI baseURI)
protected void setNamespace(String prefix, String namespace)
protected String getNamespace(String prefix) throws RDFParseException
RDFParseException
.RDFParseException
- if no namespace is associated with this prefixprotected void clear()
protected void initializeNamespaceTableFromConfiguration()
@Deprecated protected void clearBNodeIDMap()
clear()
instead.protected IRI resolveURI(String uriSpec) throws RDFParseException
IRI
object for it.RDFParseException
protected IRI createURI(String uri) throws RDFParseException
IRI
object for the specified URI-string.RDFParseException
protected Resource createNode() throws RDFParseException
RDFParseException
protected Resource createNode(String nodeID) throws RDFParseException
nodeID
- node identifierRDFParseException
@Deprecated protected BNode createBNode() throws RDFParseException
BNode
object.RDFParseException
@Deprecated protected BNode createBNode(String nodeID) throws RDFParseException
BNode
object for the specified identifier.RDFParseException
protected Literal createLiteral(String label, String lang, IRI datatype) throws RDFParseException
Literal
object with the supplied parameters.RDFParseException
protected Literal createLiteral(String label, String lang, IRI datatype, long lineNo, long columnNo) throws RDFParseException
Literal
object with the supplied parameters, using the lineNo and columnNo to enhance error
messages or exceptions that may be generated during the creation of the literal.protected Statement createStatement(Resource subj, IRI pred, Value obj) throws RDFParseException
Statement
object with the supplied components.RDFParseException
protected Statement createStatement(Resource subj, IRI pred, Value obj, Resource context) throws RDFParseException
Statement
object with the supplied components.RDFParseException
protected void reportLocation(long lineNo, long columnNo)
ParseLocationListener
, if any.protected void reportWarning(String msg)
reportWarning(String, long, long)
supplying -1 for the line- and column number.protected void reportWarning(String msg, long lineNo, long columnNo)
protected void reportError(String msg, RioSetting<Boolean> relevantSetting) throws RDFParseException
This method also throws an RDFParseException
when the given setting has been set to true and it
is not a nonFatalError.
msg
- The message to use for ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.relevantSetting
- The boolean setting that will be checked to determine if this is an issue that we need to
look at at all. If this setting is true, then the error listener will receive the error,
and if ParserConfig.isNonFatalError(RioSetting)
returns true an exception will be
thrown.RDFParseException
- If RioConfig.get(RioSetting)
returns true, and
ParserConfig.isNonFatalError(RioSetting)
returns true for the given setting.protected void reportError(String msg, long lineNo, long columnNo, RioSetting<Boolean> relevantSetting) throws RDFParseException
This method also throws an RDFParseException
when the given setting has been set to true and it
is not a nonFatalError.
msg
- The message to use for ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.lineNo
- Optional line number, should default to setting this as -1 if not known. Used for
ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.columnNo
- Optional column number, should default to setting this as -1 if not known. Used for
ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.relevantSetting
- The boolean setting that will be checked to determine if this is an issue that we need to
look at at all. If this setting is true, then the error listener will receive the error,
and if ParserConfig.isNonFatalError(RioSetting)
returns true an exception will be
thrown.RDFParseException
- If RioConfig.get(RioSetting)
returns true, and
ParserConfig.isNonFatalError(RioSetting)
returns true for the given setting.protected void reportError(Exception e, RioSetting<Boolean> relevantSetting) throws RDFParseException
This method also throws an RDFParseException
when the given setting has been set to true and it
is not a nonFatalError.
e
- The exception whose message will be used for
ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.relevantSetting
- The boolean setting that will be checked to determine if this is an issue that we need to
look at at all. If this setting is true, then the error listener will receive the error,
and if ParserConfig.isNonFatalError(RioSetting)
returns true an exception will be
thrown.RDFParseException
- If RioConfig.get(RioSetting)
returns true, and
ParserConfig.isNonFatalError(RioSetting)
returns true for the given setting.protected void reportError(Exception e, long lineNo, long columnNo, RioSetting<Boolean> relevantSetting) throws RDFParseException
This method also throws an RDFParseException
when the given setting has been set to true and it
is not a nonFatalError.
e
- The exception whose message will be used for
ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.lineNo
- Optional line number, should default to setting this as -1 if not known. Used for
ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.columnNo
- Optional column number, should default to setting this as -1 if not known. Used for
ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.relevantSetting
- The boolean setting that will be checked to determine if this is an issue that we need to
look at at all. If this setting is true, then the error listener will receive the error,
and if ParserConfig.isNonFatalError(RioSetting)
returns true an exception will be
thrown.RDFParseException
- If RioConfig.get(RioSetting)
returns true, and
ParserConfig.isNonFatalError(RioSetting)
returns true for the given setting.protected void reportError(String msg, Exception e, long lineNo, long columnNo, RioSetting<Boolean> relevantSetting) throws RDFParseException
This method also throws an RDFParseException
when the given setting has been set to true and it
is not a nonFatalError.
msg
- The message to use for ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.e
- The exception whose message will be used for
ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.lineNo
- Optional line number, should default to setting this as -1 if not known. Used for
ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.columnNo
- Optional column number, should default to setting this as -1 if not known. Used for
ParseErrorListener.error(String, long, long)
and for
RDFParseException(String, long, long)
.relevantSetting
- The boolean setting that will be checked to determine if this is an issue that we need to
look at at all. If this setting is true, then the error listener will receive the error,
and if ParserConfig.isNonFatalError(RioSetting)
returns true an exception will be
thrown.RDFParseException
- If RioConfig.get(RioSetting)
returns true, and
ParserConfig.isNonFatalError(RioSetting)
returns true for the given setting.protected void reportFatalError(String msg) throws RDFParseException
reportFatalError(String, long, long)
supplying -1 for the
line- and column number.RDFParseException
protected void reportFatalError(String msg, long lineNo, long columnNo) throws RDFParseException
RDFParseException
protected void reportFatalError(Exception e) throws RDFParseException
RDFParseException
; in
that case the supplied exception is not wrapped in another ParseException and the error message is not reported
to the ParseErrorListener, assuming that it has already been reported when the original ParseException was
thrown.
This method simply calls reportFatalError(Exception, long, long)
supplying -1 for the line- and
column number.
RDFParseException
protected void reportFatalError(Exception e, long lineNo, long columnNo) throws RDFParseException
RDFParseException
; in that case the supplied exception is not wrapped
in another ParseException and the error message is not reported to the ParseErrorListener, assuming that it has
already been reported when the original ParseException was thrown.RDFParseException
protected void reportFatalError(String message, Exception e, long lineNo, long columnNo) throws RDFParseException
RDFParseException
; in that case the supplied exception is not wrapped
in another ParseException and the error message is not reported to the ParseErrorListener, assuming that it has
already been reported when the original ParseException was thrown.RDFParseException
Copyright © 2015-2022 Eclipse Foundation. All Rights Reserved.