org.openrdf.rio.ntriples
Class NTriplesParser

java.lang.Object
  extended by org.openrdf.rio.helpers.RDFParserBase
      extended by org.openrdf.rio.ntriples.NTriplesParser
All Implemented Interfaces:
RDFParser

public class NTriplesParser
extends RDFParserBase

RDF parser for N-Triples files. A specification of NTriples can be found in this section of the RDF Test Cases document. This parser is not thread-safe, therefore its public methods are synchronized.

Author:
Arjohn Kampman

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.openrdf.rio.RDFParser
RDFParser.DatatypeHandling
 
Field Summary
 
Fields inherited from class org.openrdf.rio.helpers.RDFParserBase
rdfHandler
 
Constructor Summary
NTriplesParser()
          Creates a new NTriplesParser that will use a ValueFactoryImpl to create object for resources, bNodes and literals.
NTriplesParser(ValueFactory valueFactory)
          Creates a new NTriplesParser that will use the supplied ValueFactory to create RDF model objects.
 
Method Summary
protected  Literal createLiteral(String label, String lang, String datatype)
           
protected  URI createURI(String uri)
          Creates a URI object for the specified URI-string.
 RDFFormat getRDFFormat()
          Gets the RDF format that this parser can parse.
 void parse(InputStream in, String baseURI)
          Implementation of the parse(InputStream, String) method defined in the RDFParser interface.
 void parse(Reader reader, String baseURI)
          Implementation of the parse(Reader, String) method defined in the RDFParser interface.
protected  void reportError(String msg)
          Overrides RDFParserBase.reportError(String), adding line number information to the error.
protected  void reportFatalError(Exception e)
          Overrides RDFParserBase.reportFatalError(Exception), adding line number information to the error.
protected  void reportFatalError(String msg)
          Overrides RDFParserBase.reportFatalError(String), adding line number information to the error.
protected  void reportWarning(String msg)
          Overrides RDFParserBase.reportWarning(String), adding line number information to the error.
 
Methods inherited from class org.openrdf.rio.helpers.RDFParserBase
clear, clearBNodeIDMap, createBNode, createBNode, createLiteral, createStatement, createStatement, datatypeHandling, getNamespace, getParseErrorListener, getParseLocationListener, getRDFHandler, preserveBNodeIDs, reportError, reportFatalError, reportFatalError, reportLocation, reportWarning, resolveURI, setBaseURI, setBaseURI, setDatatypeHandling, setNamespace, setParseErrorListener, setParseLocationListener, setPreserveBNodeIDs, setRDFHandler, setStopAtFirstError, setValueFactory, setVerifyData, stopAtFirstError, verifyData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NTriplesParser

public NTriplesParser()
Creates a new NTriplesParser that will use a ValueFactoryImpl to create object for resources, bNodes and literals.


NTriplesParser

public NTriplesParser(ValueFactory valueFactory)
Creates a new NTriplesParser that will use the supplied ValueFactory to create RDF model objects.

Parameters:
valueFactory - A ValueFactory.
Method Detail

getRDFFormat

public final RDFFormat getRDFFormat()
Description copied from interface: RDFParser
Gets the RDF format that this parser can parse.


parse

public void parse(InputStream in,
                  String baseURI)
           throws IOException,
                  RDFParseException,
                  RDFHandlerException
Implementation of the parse(InputStream, String) method defined in the RDFParser interface.

Parameters:
in - The InputStream from which to read the data, must not be null. The InputStream is supposed to contain 7-bit US-ASCII characters, as per the N-Triples specification.
baseURI - The URI associated with the data in the InputStream, must not be null.
Throws:
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 encountered an unrecoverable error.
IllegalArgumentException - If the supplied input stream or base URI is null.

parse

public void parse(Reader reader,
                  String baseURI)
           throws IOException,
                  RDFParseException,
                  RDFHandlerException
Implementation of the parse(Reader, String) method defined in the RDFParser interface.

Parameters:
reader - The Reader from which to read the data, must not be null.
baseURI - The URI associated with the data in the Reader, must not be null.
Throws:
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 encountered an unrecoverable error.
IllegalArgumentException - If the supplied reader or base URI is null.

createURI

protected URI createURI(String uri)
                 throws RDFParseException
Description copied from class: RDFParserBase
Creates a URI object for the specified URI-string.

Overrides:
createURI in class RDFParserBase
Throws:
RDFParseException

createLiteral

protected Literal createLiteral(String label,
                                String lang,
                                String datatype)
                         throws RDFParseException
Throws:
RDFParseException

reportWarning

protected void reportWarning(String msg)
Overrides RDFParserBase.reportWarning(String), adding line number information to the error.

Overrides:
reportWarning in class RDFParserBase

reportError

protected void reportError(String msg)
                    throws RDFParseException
Overrides RDFParserBase.reportError(String), adding line number information to the error.

Overrides:
reportError in class RDFParserBase
Throws:
RDFParseException
See Also:
RDFParserBase.setStopAtFirstError(boolean)

reportFatalError

protected void reportFatalError(String msg)
                         throws RDFParseException
Overrides RDFParserBase.reportFatalError(String), adding line number information to the error.

Overrides:
reportFatalError in class RDFParserBase
Throws:
RDFParseException

reportFatalError

protected void reportFatalError(Exception e)
                         throws RDFParseException
Overrides RDFParserBase.reportFatalError(Exception), adding line number information to the error.

Overrides:
reportFatalError in class RDFParserBase
Throws:
RDFParseException


Copyright © 2001-2007 Aduna. All Rights Reserved.