com.hp.hpl.jena.rdf.arp
Class ARP

java.lang.Object
  |
  +--com.hp.hpl.jena.rdf.arp.ARP
All Implemented Interfaces:
ARPErrorNumbers

public class ARP
extends java.lang.Object
implements ARPErrorNumbers

Another RDF Parser. To load an RDF file:

  • Create an ARP.
  • Set its StatementHandler.
  • Optionally, modify the error handling.
  • Call a load method.
  • Xerces is used for parsing the XML. The SAXEvents generated by Xerces are then analysed as RDF by ARP. Errors may occur in either the XML or the RDF part, see setErrorHandler for details of how to distinguish between them.


    Fields inherited from interface com.hp.hpl.jena.rdf.arp.ARPErrorNumbers
    EM_ERROR, EM_FATAL, EM_IGNORE, EM_WARNING, ERR_ABOUTEACH_NOT_TOPLEVEL, ERR_INTERNAL_ERROR, ERR_NOT_WHITESPACE, ERR_SYNTAX_ERROR, ERR_UNABLE_TO_RECOVER, IGN_PRIVATE_XMLLANG, IGN_XMLBASE_SIGNIFICANT, IGN_XMLBASE_USED, WARN_BAD_NAME, WARN_BAD_XML, WARN_BAD_XMLLANG, WARN_DEPRECATED_XMLLANG, WARN_EMPTY_ABOUT_EACH, WARN_LI_AS_TYPE, WARN_MALFORMED_URI, WARN_MALFORMED_XMLLANG, WARN_MINOR_INTERNAL_ERROR, WARN_REDEFINITION_OF_ID, WARN_RELATIVE_NAMESPACE_URI_DEPRECATED, WARN_UNKNOWN_PARSETYPE, WARN_UNKNOWN_RDF_ATTRIBUTE, WARN_UNKNOWN_RDF_ELEMENT, WARN_UNKNOWN_XML_ATTRIBUTE, WARN_UNQUALIFIED_ATTRIBUTE, WARN_UNQUALIFIED_ELEMENT, WARN_UNQUALIFIED_RDF_ATTRIBUTE, WARN_XMLBASE_MISSING
     
    Constructor Summary
    ARP()
              Creates a new RDF Parser.
     
    Method Summary
     void load(java.io.InputStream in)
              Load RDF/XML from an InputStream, using base URL http://unknown.org/.
     void load(java.io.InputStream in, java.lang.String xmlBase)
              Load RDF/XML from an InputStream.
     void load(java.io.Reader in)
              Load RDF/XML from a Reader, using base URL http://unknown.org/.
     void load(java.io.Reader in, java.lang.String xmlBase)
              Load RDF/XML from a Reader.
     void setDefaultErrorMode()
              Resets error mode to the default values: most errors are reported as warnings, but triples are produced.
     void setEmbedding(boolean embed)
              Sets whether the XML document is only RDF, or contains RDF embedded in other XML.
     void setErrorHandler(org.xml.sax.ErrorHandler eh)
              Sets the error handler, for both XML and RDF parse errors.
     int setErrorMode(int errno, int mode)
              Sets or gets the error handling mode for a specific error condition.
     void setLaxErrorMode()
              As many errors as possible are ignored.
     StatementHandler setStatementHandler(StatementHandler sh)
              Sets the StatementHandler that provides the callback mechanism for each triple in the file.
     void setStrictErrorMode()
              This method tries to emulate the latest Working Group recommendations.
     void setStrictErrorMode(int nonErrorMode)
              This method detects and prohibits errors according to the latest Working Group recommendations.
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    ARP

    public ARP()
    Creates a new RDF Parser. Can parse one file at a time.
    Method Detail

    setStatementHandler

    public StatementHandler setStatementHandler(StatementHandler sh)
    Sets the StatementHandler that provides the callback mechanism for each triple in the file.
    Parameters:
    sh - The statement handler to use.
    Returns:
    The old statement handler.

    setErrorHandler

    public void setErrorHandler(org.xml.sax.ErrorHandler eh)
    Sets the error handler, for both XML and RDF parse errors. XML errors are reported by Xerces, as instances of SAXParseException; the RDF errors are reported from ARP as instances of ParseException. Code that needs to distingusih between them may look like:
       void error( SAXParseException e ) throws SAXException {
         if ( e instanceof com.hp.hpl.jena.rdf.arp.ParseException ) {
              ...
         } else {
              ...
         }
       }
     

    See the ARP documentation for ErrorHandler for details of the ErrorHandler semantics (in particular how to upgrade a warning to an error, and an error to a fatalError).

    The Xerces/SAX documentation for ErrorHandler is available on the web.

    Parameters:
    eh - The error handler to use.

    setErrorMode

    public int setErrorMode(int errno,
                            int mode)
    Sets or gets the error handling mode for a specific error condition. Changes that cannot be honoured are silently ignored. Illegal error numbers may result in an ArrayIndexOutOfBoundsException but are usually ignored.
    Parameters:
    errno - The specific error condition to change.
    mode - The new mode one of:
    IGNORE
    Ignore this condition.
    WARNING
    Invoke ErrorHandler.warning() for this condition.
    ERROR
    Invoke ErrorHandler.error() for this condition.
    FATAL
    Aborts parse and invokes ErrorHandler.fatalError() for this condition. In unusual situations, a few further warnings and errors may be reported.
    Returns:
    The old error mode for this condition.

    setDefaultErrorMode

    public void setDefaultErrorMode()
    Resets error mode to the default values: most errors are reported as warnings, but triples are produced.

    setLaxErrorMode

    public void setLaxErrorMode()
    As many errors as possible are ignored. As many triples as possible are produced.

    setStrictErrorMode

    public void setStrictErrorMode()
    This method tries to emulate the latest Working Group recommendations.

    setStrictErrorMode

    public void setStrictErrorMode(int nonErrorMode)
    This method detects and prohibits errors according to the latest Working Group recommendations. For other conditions, such as ARPErrorNumbers.WARN_EMPTY_ABOUT_EACH and ARPErrorNumbers.WARN_LI_AS_TYPE, nonErrorMode is used.
    Parameters:
    nonErrorMode - The way of treating non-error conditions.

    setEmbedding

    public void setEmbedding(boolean embed)
    Sets whether the XML document is only RDF, or contains RDF embedded in other XML. The default is embedded mode, which also matches RDF documents that use the rdf:RDF tag at the top-level. To match RDF documents which omit that optional tag, and consist of a single rdf:Description or typed node, it is necessary to setEmbedding(false).
    Parameters:
    embed - true: Look for embedded RDF (the default); or false: match a typed node or rdf:Description against the whole document.

    load

    public void load(java.io.Reader in,
                     java.lang.String xmlBase)
              throws org.xml.sax.SAXException,
                     java.io.IOException
    Load RDF/XML from a Reader.
    Parameters:
    in - The input XML document.
    xmlBase - The base URI for the document.
    Throws:
    org.xml.sax.SAXException - More serious error during XML or RDF processing; or thrown from the fatalError method of the ErrorHandler.
    java.io.IOException - Occurring during XML processing.

    load

    public void load(java.io.InputStream in,
                     java.lang.String xmlBase)
              throws org.xml.sax.SAXException,
                     java.io.IOException
    Load RDF/XML from an InputStream.
    Parameters:
    in - The input XML document.
    xmlBase - The base URI for the document.
    Throws:
    org.xml.sax.SAXException - More serious error during XML or RDF processing; or thrown from the fatalError method of the ErrorHandler.
    java.io.IOException - Occurring during XML processing.

    load

    public void load(java.io.InputStream in)
              throws org.xml.sax.SAXException,
                     java.io.IOException
    Load RDF/XML from an InputStream, using base URL http://unknown.org/.
    Parameters:
    in - The input XML document.
    Throws:
    org.xml.sax.SAXException - More serious error during XML or RDF processing; or thrown from the fatalError method of the ErrorHandler.
    java.io.IOException - Occurring during XML processing.

    load

    public void load(java.io.Reader in)
              throws org.xml.sax.SAXException,
                     java.io.IOException
    Load RDF/XML from a Reader, using base URL http://unknown.org/.
    Parameters:
    in - The input XML document.
    Throws:
    org.xml.sax.SAXException - More serious error during XML or RDF processing; or thrown from the fatalError method of the ErrorHandler.
    java.io.IOException - Occurring during XML processing.


    Copyright 2001 Hewlett-Packard. All Rights Reserved.