|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jrdf.parser.rdfxml.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.
To parse a document using this parser:
Graph jrdfGraph = new GraphImpl(); Parser parser = new RdfXmlParser(jrdfGraph); parser.setStatementHandler(myStatementHandler); parser.setParseErrorListener(myParseErrorListener); parser.setVerifyData(true); parser.stopAtFirstError(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.Parser |
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 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 baseURI to resolve any relative URI references. |
void |
parse(Reader reader,
String baseURI)
Parses the data from the supplied Reader, using the supplied baseURI 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.public RdfXmlParser(GraphElementFactory valueFactory, ParserBlankNodeFactory parserBlankNodeFactory) throws GraphException
valueFactory
- A GraphElementFactory.parserBlankNodeFactory
- A ParserBlankNodeFactory.Method Detail |
public void setStatementHandler(StatementHandler sh)
Parser
setStatementHandler
in interface Parser
sh
- the StatementHandler.public void setParseErrorListener(ParseErrorListener el)
Parser
setParseErrorListener
in interface Parser
el
- the error listener.public void setParseLocationListener(ParseLocationListener ll)
Parser
setParseLocationListener
in interface Parser
ll
- the parser location listener.public void setNamespaceListener(NamespaceListener nl)
Parser
setNamespaceListener
in interface Parser
nl
- the namespace listener.public void setVerifyData(boolean verifyData)
Parser
setVerifyData
in interface Parser
verifyData
- true to verify the data parsed in.public void setPreserveBNodeIds(boolean preserveBNodeIds)
Parser
setPreserveBNodeIds
in interface Parser
preserveBNodeIds
- true to presever blank node identifier.public void setStopAtFirstError(boolean stopAtFirstError)
Parser
setStopAtFirstError
in interface Parser
stopAtFirstError
- true if an error should stop parsing.public void setDatatypeHandling(int datatypeHandling)
Parser
setDatatypeHandling
in interface Parser
datatypeHandling
- One of the constants
DT_IGNORE, DT_VERIFY or
DT_NORMALIZE.Parser.DT_IGNORE
,
Parser.DT_VERIFY
,
Parser.DT_NORMALIZE
public void setParseStandAloneDocuments(boolean standAloneDocs)
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 |