org.jrdf.parser
Interface Parser

All Known Implementing Classes:
RdfXmlParser

public interface Parser

A general interface for RDF parsers.


Field Summary
static int DT_IGNORE
          Constant indicating that datatypes semantics should be ignored.
static int DT_NORMALIZE
          Constant indicating that values of datatyped literals should be normalized to their canonical representation.
static int DT_VERIFY
          Constant indicating that values of datatyped literals should be verified.
 
Method Summary
 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 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).
 

Field Detail

DT_IGNORE

public static final int DT_IGNORE
Constant indicating that datatypes semantics should be ignored.

See Also:
Constant Field Values

DT_VERIFY

public static final int DT_VERIFY
Constant indicating that values of datatyped literals should be verified.

See Also:
Constant Field Values

DT_NORMALIZE

public static final int DT_NORMALIZE
Constant indicating that values of datatyped literals should be normalized to their canonical representation.

See Also:
Constant Field Values
Method Detail

setStatementHandler

public void setStatementHandler(StatementHandler sh)
Sets the StatementHandler that will be notified of statements that are parsed by this parser.

Parameters:
sh - the StatementHandler.

setParseErrorListener

public void setParseErrorListener(ParseErrorListener el)
Sets the ParseErrorListener that will be notified of any errors that this parser finds during parsing.

Parameters:
el - the error listener.

setParseLocationListener

public void setParseLocationListener(ParseLocationListener ll)
Sets the ParseLocationListener that will be notified of the parser's progress during the parse process.

Parameters:
ll - the parser location listener.

setNamespaceListener

public void setNamespaceListener(NamespaceListener nl)
Sets the NamespaceListener that will be notified of any namespace declarations that the parser finds during parsing.

Parameters:
nl - the namespace listener.

setVerifyData

public void setVerifyData(boolean verifyData)
Sets whether the parser should verify the data it parses (default value is true).

Parameters:
verifyData - true to verify the data parsed in.

setPreserveBNodeIds

public void setPreserveBNodeIds(boolean preserveBNodeIds)
Set whether the parser should preserve bnode identifiers specified in the source (default is false).

Parameters:
preserveBNodeIds - true to presever blank node identifier.

setStopAtFirstError

public void setStopAtFirstError(boolean stopAtFirstError)
Sets whether the parser should stop immediately if it finds an error in the data (default value is true).

Parameters:
stopAtFirstError - true if an error should stop parsing.

setDatatypeHandling

public void setDatatypeHandling(int datatypeHandling)
Sets the datatype handling mode. There are three modes for handling datatyped literals: ignore, verify and normalize. If set to ignore, no special action will be taken to handle datatyped literals. If set to verify (the default value), any literals with known (XML Schema built-in) datatypes are checked to see if their values are valid. If set to normalize, the literal values are not only checked, but also normalized to their canonical representation. The default value is verify.

Parameters:
datatypeHandling - One of the constants DT_IGNORE, DT_VERIFY or DT_NORMALIZE.
See Also:
DT_IGNORE, DT_VERIFY, DT_NORMALIZE

parse

public void parse(InputStream in,
                  String baseURI)
           throws IOException,
                  ParseException,
                  StatementHandlerException
Parses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI references.

Parameters:
in - The InputStream from which to read the data.
baseURI - The URI associated with the data in the InputStream.
Throws:
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.

parse

public void parse(Reader reader,
                  String baseURI)
           throws IOException,
                  ParseException,
                  StatementHandlerException
Parses the data from the supplied Reader, using the supplied baseURI to resolve any relative URI references.

Parameters:
reader - The Reader from which to read the data.
baseURI - The URI associated with the data in the InputStream.
Throws:
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.