Package org.eclipse.rdf4j.rio.trix
Class TriXParser
java.lang.Object
org.eclipse.rdf4j.rio.helpers.AbstractRDFParser
org.eclipse.rdf4j.rio.helpers.XMLReaderBasedParser
org.eclipse.rdf4j.rio.trix.TriXParser
- All Implemented Interfaces:
RDFParser
,ErrorHandler
A parser that can parse RDF files that are in the TriX format .
- Author:
- Arjohn Kampman
-
Field Summary
Fields inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFParser
rdfHandler, valueFactory
-
Constructor Summary
ConstructorDescriptionCreates a new TriXParser that will use aSimpleValueFactory
to create objects for resources, bNodes, literals and statements.TriXParser
(ValueFactory valueFactory) Creates a new TriXParser that will use the supplied ValueFactory to create objects for resources, bNodes, literals and statements. -
Method Summary
Modifier and TypeMethodDescriptionprotected Literal
createLiteral
(String label, String lang, IRI datatype) Creates aLiteral
object with the supplied parameters.void
error
(SAXParseException exception) Implementation of SAX ErrorHandler.errorvoid
fatalError
(SAXParseException exception) Implementation of SAX ErrorHandler.fatalErrorfinal RDFFormat
Gets the RDF format that this parser can parse.Collection<RioSetting<?>>
void
parse
(InputStream in, String baseURI) Parses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI references.void
Parses the data from the supplied Reader, using the supplied baseURI to resolve any relative URI references.protected void
reportError
(String msg, RioSetting<Boolean> setting) OverridesAbstractRDFParser.reportError(String, RioSetting)
, adding line- and column number information to the error.protected void
OverridesAbstractRDFParser.reportFatalError(Exception)
, adding line- and column number information to the error.protected void
reportFatalError
(String msg) OverridesAbstractRDFParser.reportFatalError(String)
, adding line- and column number information to the error.protected void
reportWarning
(String msg) OverridesAbstractRDFParser.reportWarning(String)
, adding line- and column number information to the error.void
warning
(SAXParseException exception) Implementation of SAX ErrorHandler.warningMethods inherited from class org.eclipse.rdf4j.rio.helpers.XMLReaderBasedParser
getCompulsoryXmlFeatureSettings, getCompulsoryXmlPropertySettings, getOptionalXmlFeatureSettings, getOptionalXmlPropertySettings, getXMLReader
Methods inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFParser
clear, clearBNodeIDMap, createBNode, createBNode, createLiteral, createNode, createNode, createStatement, createStatement, createURI, getNamespace, getParseErrorListener, getParseLocationListener, getParserConfig, getRDFHandler, initializeNamespaceTableFromConfiguration, preserveBNodeIDs, reportError, reportError, reportError, reportError, reportFatalError, reportFatalError, reportFatalError, reportLocation, reportWarning, resolveURI, set, setBaseURI, setBaseURI, setNamespace, setParseErrorListener, setParseLocationListener, setParserConfig, setPreserveBNodeIDs, setRDFHandler, setValueFactory
-
Constructor Details
-
TriXParser
public TriXParser()Creates a new TriXParser that will use aSimpleValueFactory
to create objects for resources, bNodes, literals and statements. -
TriXParser
Creates a new TriXParser that will use the supplied ValueFactory to create objects for resources, bNodes, literals and statements.- Parameters:
valueFactory
- A ValueFactory.
-
-
Method Details
-
getRDFFormat
Description copied from interface:RDFParser
Gets the RDF format that this parser can parse.- Specified by:
getRDFFormat
in interfaceRDFParser
-
getSupportedSettings
- Specified by:
getSupportedSettings
in interfaceRDFParser
- Overrides:
getSupportedSettings
in classAbstractRDFParser
- Returns:
- A collection of
RioSetting
s that are supported by this RDFParser.
-
parse
public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException Description copied from interface:RDFParser
Parses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI references.- Specified by:
parse
in interfaceRDFParser
- Parameters:
in
- The InputStream from which to read the data.baseURI
- The URI associated with the data in the InputStream. May benull
. Parsers for syntax formats that do not support relative URIs will ignore this argument.Note that if the data contains an embedded base URI, that embedded base URI will overrule the value supplied here (see RFC 3986 section 5.1 for details).
- Throws:
IOException
- If an I/O error occurred while data was read from the InputStream.RDFParseException
- If the parser has found an unrecoverable parse error.RDFHandlerException
- If the configured statement handler has encountered an unrecoverable error.
-
parse
public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException Description copied from interface:RDFParser
Parses the data from the supplied Reader, using the supplied baseURI to resolve any relative URI references.- Specified by:
parse
in interfaceRDFParser
- Parameters:
reader
- The Reader from which to read the data.baseURI
- The URI associated with the data in the InputStream. May benull
. Parsers for syntax formats that do not support relative URIs will ignore this argument.Note that if the data contains an embedded base URI, that embedded base URI will overrule the value supplied here (see RFC 3986 section 5.1 for details).
- Throws:
IOException
- If an I/O error occurred while data was read from the InputStream.RDFParseException
- If the parser has found an unrecoverable parse error.RDFHandlerException
- If the configured statement handler has encountered an unrecoverable error.
-
createLiteral
Description copied from class:AbstractRDFParser
Creates aLiteral
object with the supplied parameters.- Overrides:
createLiteral
in classAbstractRDFParser
- Throws:
RDFParseException
-
reportWarning
OverridesAbstractRDFParser.reportWarning(String)
, adding line- and column number information to the error.- Overrides:
reportWarning
in classAbstractRDFParser
-
reportError
OverridesAbstractRDFParser.reportError(String, RioSetting)
, adding line- and column number information to the error.- Overrides:
reportError
in classAbstractRDFParser
- Parameters:
msg
- The message to use forParseErrorListener.error(String, long, long)
and forRDFParseException(String, long, long)
.setting
- 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 ifParserConfig.isNonFatalError(RioSetting)
returns true an exception will be thrown.- Throws:
RDFParseException
- IfRioConfig.get(RioSetting)
returns true, andParserConfig.isNonFatalError(RioSetting)
returns true for the given setting.
-
reportFatalError
OverridesAbstractRDFParser.reportFatalError(String)
, adding line- and column number information to the error.- Overrides:
reportFatalError
in classAbstractRDFParser
- Throws:
RDFParseException
-
reportFatalError
OverridesAbstractRDFParser.reportFatalError(Exception)
, adding line- and column number information to the error.- Overrides:
reportFatalError
in classAbstractRDFParser
- Throws:
RDFParseException
-
warning
Implementation of SAX ErrorHandler.warning- Specified by:
warning
in interfaceErrorHandler
- Throws:
SAXException
-
error
Implementation of SAX ErrorHandler.error- Specified by:
error
in interfaceErrorHandler
- Throws:
SAXException
-
fatalError
Implementation of SAX ErrorHandler.fatalError- Specified by:
fatalError
in interfaceErrorHandler
- Throws:
SAXException
-