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,org.xml.sax.ErrorHandler
public class TriXParser extends XMLReaderBasedParser implements org.xml.sax.ErrorHandler
A parser that can parse RDF files that are in the TriX format .
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classTriXParser.TriXSAXHandler
-
Field Summary
Fields Modifier and Type Field Description private SimpleSAXParsersaxParser-
Fields inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFParser
rdfHandler, valueFactory
-
-
Constructor Summary
Constructors Constructor Description TriXParser()Creates a new TriXParser that will use aSimpleValueFactoryto 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected LiteralcreateLiteral(java.lang.String label, java.lang.String lang, IRI datatype)Creates aLiteralobject with the supplied parameters.voiderror(org.xml.sax.SAXParseException exception)Implementation of SAX ErrorHandler.errorvoidfatalError(org.xml.sax.SAXParseException exception)Implementation of SAX ErrorHandler.fatalErrorRDFFormatgetRDFFormat()Gets the RDF format that this parser can parse.java.util.Collection<RioSetting<?>>getSupportedSettings()voidparse(java.io.InputStream in, java.lang.String baseURI)Parses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI references.voidparse(java.io.Reader reader, java.lang.String baseURI)Parses the data from the supplied Reader, using the supplied baseURI to resolve any relative URI references.private voidparse(org.xml.sax.InputSource inputStreamOrReader)protected voidreportError(java.lang.String msg, RioSetting<java.lang.Boolean> setting)OverridesAbstractRDFParser.reportError(String, RioSetting), adding line- and column number information to the error.protected voidreportFatalError(java.lang.Exception e)OverridesAbstractRDFParser.reportFatalError(Exception), adding line- and column number information to the error.protected voidreportFatalError(java.lang.String msg)OverridesAbstractRDFParser.reportFatalError(String), adding line- and column number information to the error.protected voidreportWarning(java.lang.String msg)OverridesAbstractRDFParser.reportWarning(String), adding line- and column number information to the error.voidwarning(org.xml.sax.SAXParseException exception)Implementation of SAX ErrorHandler.warning-
Methods 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
-
-
-
-
Field Detail
-
saxParser
private SimpleSAXParser saxParser
-
-
Constructor Detail
-
TriXParser
public TriXParser()
Creates a new TriXParser that will use aSimpleValueFactoryto create objects for resources, bNodes, literals and statements.
-
TriXParser
public TriXParser(ValueFactory valueFactory)
Creates a new TriXParser that will use the supplied ValueFactory to create objects for resources, bNodes, literals and statements.- Parameters:
valueFactory- A ValueFactory.
-
-
Method Detail
-
getRDFFormat
public final RDFFormat getRDFFormat()
Description copied from interface:RDFParserGets the RDF format that this parser can parse.- Specified by:
getRDFFormatin interfaceRDFParser
-
getSupportedSettings
public java.util.Collection<RioSetting<?>> getSupportedSettings()
- Specified by:
getSupportedSettingsin interfaceRDFParser- Overrides:
getSupportedSettingsin classAbstractRDFParser- Returns:
- A collection of
RioSettings that are supported by this RDFParser.
-
parse
public void parse(java.io.InputStream in, java.lang.String baseURI) throws java.io.IOException, RDFParseException, RDFHandlerExceptionDescription copied from interface:RDFParserParses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI references.- Specified by:
parsein 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:
java.io.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(java.io.Reader reader, java.lang.String baseURI) throws java.io.IOException, RDFParseException, RDFHandlerExceptionDescription copied from interface:RDFParserParses the data from the supplied Reader, using the supplied baseURI to resolve any relative URI references.- Specified by:
parsein 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:
java.io.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
private void parse(org.xml.sax.InputSource inputStreamOrReader) throws java.io.IOException, RDFParseException, RDFHandlerException- Throws:
java.io.IOExceptionRDFParseExceptionRDFHandlerException
-
createLiteral
protected Literal createLiteral(java.lang.String label, java.lang.String lang, IRI datatype) throws RDFParseException
Description copied from class:AbstractRDFParserCreates aLiteralobject with the supplied parameters.- Overrides:
createLiteralin classAbstractRDFParser- Throws:
RDFParseException
-
reportWarning
protected void reportWarning(java.lang.String msg)
OverridesAbstractRDFParser.reportWarning(String), adding line- and column number information to the error.- Overrides:
reportWarningin classAbstractRDFParser
-
reportError
protected void reportError(java.lang.String msg, RioSetting<java.lang.Boolean> setting) throws RDFParseExceptionOverridesAbstractRDFParser.reportError(String, RioSetting), adding line- and column number information to the error.- Overrides:
reportErrorin 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
protected void reportFatalError(java.lang.String msg) throws RDFParseExceptionOverridesAbstractRDFParser.reportFatalError(String), adding line- and column number information to the error.- Overrides:
reportFatalErrorin classAbstractRDFParser- Throws:
RDFParseException
-
reportFatalError
protected void reportFatalError(java.lang.Exception e) throws RDFParseExceptionOverridesAbstractRDFParser.reportFatalError(Exception), adding line- and column number information to the error.- Overrides:
reportFatalErrorin classAbstractRDFParser- Throws:
RDFParseException
-
warning
public void warning(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXExceptionImplementation of SAX ErrorHandler.warning- Specified by:
warningin interfaceorg.xml.sax.ErrorHandler- Throws:
org.xml.sax.SAXException
-
error
public void error(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXExceptionImplementation of SAX ErrorHandler.error- Specified by:
errorin interfaceorg.xml.sax.ErrorHandler- Throws:
org.xml.sax.SAXException
-
fatalError
public void fatalError(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXExceptionImplementation of SAX ErrorHandler.fatalError- Specified by:
fatalErrorin interfaceorg.xml.sax.ErrorHandler- Throws:
org.xml.sax.SAXException
-
-