public final class UTLFParser extends Object implements org.jrdf.parser.ConfigurableParser
org.xml.sax.driver
property.
This parser is not thread-safe, therefore it's public methods are
synchronized.
To parse a document using this parser:
Graph jrdfGraph = new GraphImpl(); Parser parser = new UTLFParser(jrdfGraph.getElementFactory()); parser.setStatementHandler(myStatementHandler); parser.setParseErrorListener(myParseErrorListener); parser.setVerifyData(true); parser.setStopAtFirstError(false); // Parse the data from inputStream, resolving any relative URIs against http://foo/bar: parser.parse(inputStream, "http://foo/bar");
Modifier and Type | Class and Description |
---|---|
(package private) static interface |
UTLFParser.Element |
(package private) static class |
UTLFParser.NodeElement |
(package private) static class |
UTLFParser.PropertyElement |
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
preserveBNodeIds
Flag indicating whether the parser should preserve bnode identifiers specified
in the source.
|
(package private) boolean |
verifyData
Flag indicating whether the parser should check the data it parses.
|
Constructor and Description |
---|
UTLFParser(org.jrdf.graph.GraphElementFactory graphElementFactory)
Creates a new UTLFParser that will use the supplied GraphElementFactory to create objects for resources,
bNodes and literals.
|
UTLFParser(org.jrdf.graph.GraphElementFactory graphElementFactory,
org.jrdf.map.MapFactory creator)
Creates a new UTLFParser that will use the supplied BlankNodeFactoryCreator and create a new map to be used
by the generic ParserBlankNodeFactoryImpl.
|
UTLFParser(org.jrdf.graph.GraphElementFactory valueFactory,
org.jrdf.parser.ParserBlankNodeFactory parserBlankNodeFactory)
Creates a new UTLFParser that will use the supplied GraphElementFactory
to create objects for resources, bNodes and literals.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
emptyElement(String namespaceURI,
String localName,
String qName,
Atts atts) |
(package private) void |
endElement(String namespaceURI,
String localName,
String qName) |
boolean |
getParseStandAloneDocuments()
Returns whether the parser is currently in a mode to parse stand-alone
RDF documents.
|
void |
parse(InputStream in,
String baseURI)
Parses the data from the supplied InputStream, using the supplied
BASE_URI to resolve any relative URI references.
|
void |
parse(Reader reader,
String baseURI)
Parses the data from the supplied Reader, using the supplied BASE_URI
to resolve any relative URI references.
|
(package private) void |
sendError(String msg) |
(package private) void |
sendFatalError(String msg) |
(package private) void |
sendWarning(String msg) |
(package private) void |
setBaseURI(URI baseURI) |
void |
setDatatypeHandling(int datatypeHandling) |
void |
setNamespaceListener(org.jrdf.parser.NamespaceListener nl) |
void |
setParseErrorListener(org.jrdf.parser.ParseErrorListener el) |
void |
setParseLocationListener(org.jrdf.parser.ParseLocationListener ll) |
void |
setParseStandAloneDocuments(boolean standAloneDocs) |
void |
setPreserveBNodeIds(boolean preserveBNodeIds) |
void |
setStatementHandler(org.jrdf.parser.StatementHandler sh) |
void |
setStopAtFirstError(boolean stopAtFirstError) |
void |
setVerifyData(boolean verifyData) |
(package private) void |
setXmlLang(String xmlLang) |
(package private) void |
startElement(String namespaceURI,
String localName,
String qName,
Atts atts) |
(package private) void |
text(String text) |
boolean verifyData
boolean preserveBNodeIds
public UTLFParser(org.jrdf.graph.GraphElementFactory graphElementFactory) throws org.jrdf.graph.GraphException
graphElementFactory
- A GraphElementFactory.org.jrdf.graph.GraphException
- Graph Exceptionpublic UTLFParser(org.jrdf.graph.GraphElementFactory graphElementFactory, org.jrdf.map.MapFactory creator) throws org.jrdf.graph.GraphException
graphElementFactory
- A GraphElementFactory.creator
- A BlankNodeFactoryCreator.org.jrdf.graph.GraphException
- Graph Exceptionpublic UTLFParser(org.jrdf.graph.GraphElementFactory valueFactory, org.jrdf.parser.ParserBlankNodeFactory parserBlankNodeFactory) throws org.jrdf.graph.GraphException
valueFactory
- A GraphElementFactory.parserBlankNodeFactory
- A ParserBlankNodeFactory.org.jrdf.graph.GraphException
- Graph Exceptionpublic void setStatementHandler(org.jrdf.parser.StatementHandler sh)
setStatementHandler
in interface org.jrdf.parser.StatementHandlerConfiguration
public void setParseErrorListener(org.jrdf.parser.ParseErrorListener el)
setParseErrorListener
in interface org.jrdf.parser.ParserConfiguration
public void setParseLocationListener(org.jrdf.parser.ParseLocationListener ll)
setParseLocationListener
in interface org.jrdf.parser.ParserConfiguration
public void setNamespaceListener(org.jrdf.parser.NamespaceListener nl)
setNamespaceListener
in interface org.jrdf.parser.ParserConfiguration
public void setVerifyData(boolean verifyData)
setVerifyData
in interface org.jrdf.parser.ParserConfiguration
public void setPreserveBNodeIds(boolean preserveBNodeIds)
setPreserveBNodeIds
in interface org.jrdf.parser.ParserConfiguration
public void setStopAtFirstError(boolean stopAtFirstError)
setStopAtFirstError
in interface org.jrdf.parser.ParserConfiguration
public void setDatatypeHandling(int datatypeHandling)
setDatatypeHandling
in interface org.jrdf.parser.ParserConfiguration
public void setParseStandAloneDocuments(boolean standAloneDocs)
setParseStandAloneDocuments
in interface org.jrdf.parser.ParserConfiguration
public boolean getParseStandAloneDocuments()
setParseStandAloneDocuments(boolean)
public void parse(InputStream in, String baseURI) throws IOException, org.jrdf.parser.ParseException, org.jrdf.parser.StatementHandlerException
parse
in interface org.jrdf.parser.Parser
in
- The InputStream from which to read the data.baseURI
- The URI associated with the data in the InputStream.IOException
- If an I/O error occurred while data was read
from the InputStream.org.jrdf.parser.ParseException
- If the parser has found an unrecoverable
parse error.org.jrdf.parser.StatementHandlerException
- If the configured statement handler
encountered an unrecoverable error.IllegalArgumentException
- If the supplied input stream or
base URI is null.public void parse(Reader reader, String baseURI) throws IOException, org.jrdf.parser.ParseException, org.jrdf.parser.StatementHandlerException
parse
in interface org.jrdf.parser.Parser
reader
- The Reader from which to read the data.baseURI
- The URI associated with the data in the InputStream.IOException
- If an I/O error occurred while data was read
from the InputStream.org.jrdf.parser.ParseException
- If the parser has found an unrecoverable
parse error.org.jrdf.parser.StatementHandlerException
- If the configured statement handler
has encountered an unrecoverable error.IllegalArgumentException
- If the supplied reader or base URI
is null.void setBaseURI(URI baseURI)
void setXmlLang(String xmlLang)
void startElement(String namespaceURI, String localName, String qName, Atts atts) throws SAXException
SAXException
void endElement(String namespaceURI, String localName, String qName) throws SAXException
SAXException
void emptyElement(String namespaceURI, String localName, String qName, Atts atts) throws SAXException
SAXException
void text(String text) throws SAXException
SAXException
void sendWarning(String msg)
void sendError(String msg) throws SAXException
SAXException
void sendFatalError(String msg) throws SAXException
SAXException
EDB Working Group at Tue Jun 10 17:08:59 JST 2025