|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jrdf.parser.rdfxml.RdfXmlParser
public final class RdfXmlParser
A parser for XML-serialized RDF. This parser operates directly
on the SAX events generated by a SAX-enabled XML parser. The XML parser
should be compliant with SAX2. You should specify which SAX parser should
be used by setting the org.xml.sax.driver
property.
This parser is not thread-safe, therefore it's public methods are
synchronized.
Graph jrdfGraph = new GraphImpl(); Parser parser = new RdfXmlParser(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");
Field Summary |
---|
Fields inherited from interface org.jrdf.parser.ParserConfiguration |
---|
DT_IGNORE, DT_NORMALIZE, DT_VERIFY |
Constructor Summary | |
---|---|
RdfXmlParser(GraphElementFactory graphElementFactory)
Creates a new RdfXmlParser that will use the supplied GraphElementFactory to create objects for resources, bNodes and literals. |
|
RdfXmlParser(GraphElementFactory graphElementFactory,
MapFactory creator)
Creates a new RdfXmlParser that will use the supplied BlankNodeFactoryCreator and create a new map to be used by the generic ParserBlankNodeFactoryImpl. |
|
RdfXmlParser(GraphElementFactory valueFactory,
ParserBlankNodeFactory parserBlankNodeFactory)
Creates a new RdfXmlParser that will use the supplied GraphElementFactory to create objects for resources, bNodes and literals. |
Method Summary | |
---|---|
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. |
void |
setDatatypeHandling(int datatypeHandling)
Sets the datatype handling mode. |
void |
setNamespaceListener(NamespaceListener nl)
Sets the NamespaceListener that will be notified of any namespace declarations that the parser finds during parsing. |
void |
setParseErrorListener(ParseErrorListener el)
Sets the ParseErrorListener that will be notified of any errors that this parser finds during parsing. |
void |
setParseLocationListener(ParseLocationListener ll)
Sets the ParseLocationListener that will be notified of the parser's progress during the parse process. |
void |
setParseStandAloneDocuments(boolean standAloneDocs)
Sets the parser in a mode to parse stand-alone RDF documents. |
void |
setPreserveBNodeIds(boolean preserveBNodeIds)
Set whether the parser should preserve bnode identifiers specified in the source (default is false). |
void |
setStatementHandler(StatementHandler sh)
Sets the StatementHandler that will be notified of statements that are parsed by this parser. |
void |
setStopAtFirstError(boolean stopAtFirstError)
Sets whether the parser should stop immediately if it finds an error in the data (default value is true). |
void |
setVerifyData(boolean verifyData)
Sets whether the parser should verify the data it parses (default value is true). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RdfXmlParser(GraphElementFactory graphElementFactory) throws GraphException
graphElementFactory
- A GraphElementFactory.
GraphException
public RdfXmlParser(GraphElementFactory graphElementFactory, MapFactory creator) throws GraphException
graphElementFactory
- A GraphElementFactory.creator
- A BlankNodeFactoryCreator.
GraphException
public RdfXmlParser(GraphElementFactory valueFactory, ParserBlankNodeFactory parserBlankNodeFactory) throws GraphException
valueFactory
- A GraphElementFactory.parserBlankNodeFactory
- A ParserBlankNodeFactory.
GraphException
Method Detail |
---|
public void setStatementHandler(StatementHandler sh)
StatementHandlerConfiguration
setStatementHandler
in interface StatementHandlerConfiguration
sh
- the StatementHandler.public void setParseErrorListener(ParseErrorListener el)
ParserConfiguration
setParseErrorListener
in interface ParserConfiguration
el
- the error listener.public void setParseLocationListener(ParseLocationListener ll)
ParserConfiguration
setParseLocationListener
in interface ParserConfiguration
ll
- the parser location listener.public void setNamespaceListener(NamespaceListener nl)
ParserConfiguration
setNamespaceListener
in interface ParserConfiguration
nl
- the namespace listener.public void setVerifyData(boolean verifyData)
ParserConfiguration
setVerifyData
in interface ParserConfiguration
verifyData
- true to verify the data parsed in.public void setPreserveBNodeIds(boolean preserveBNodeIds)
ParserConfiguration
setPreserveBNodeIds
in interface ParserConfiguration
preserveBNodeIds
- true to presever blank node identifier.public void setStopAtFirstError(boolean stopAtFirstError)
ParserConfiguration
setStopAtFirstError
in interface ParserConfiguration
stopAtFirstError
- true if an error should stop parsing.public void setDatatypeHandling(int datatypeHandling)
ParserConfiguration
setDatatypeHandling
in interface ParserConfiguration
datatypeHandling
- One of the constants
DT_IGNORE, DT_VERIFY or
DT_NORMALIZE.ParserConfiguration.DT_IGNORE
,
ParserConfiguration.DT_VERIFY
,
ParserConfiguration.DT_NORMALIZE
public void setParseStandAloneDocuments(boolean standAloneDocs)
ParserConfiguration
setParseStandAloneDocuments
in interface ParserConfiguration
standAloneDocs
- true in standad alone mode.public boolean getParseStandAloneDocuments()
setParseStandAloneDocuments(boolean)
public void parse(InputStream in, String baseURI) throws IOException, ParseException, StatementHandlerException
parse
in interface 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.
ParseException
- If the parser has found an unrecoverable
parse error.
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, ParseException, StatementHandlerException
parse
in interface 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.
ParseException
- If the parser has found an unrecoverable
parse error.
StatementHandlerException
- If the configured statement handler
has encountered an unrecoverable error.
IllegalArgumentException
- If the supplied reader or base URI
is null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |