edu.unika.aifb.rdf.api.syntax
Class RDFParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by edu.unika.aifb.rdf.api.syntax.RDFParser
All Implemented Interfaces:
RDFConstants, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class RDFParser
extends org.xml.sax.helpers.DefaultHandler
implements RDFConstants

This class parses the RDF according to the syntax specified in http://www.w3.org/TR/rdf-syntax-grammar/.


Field Summary
 
Fields inherited from interface edu.unika.aifb.rdf.api.util.RDFConstants
ATTR_ABOUT, ATTR_ABOUT_EACH, ATTR_ABOUT_EACH_PREFIX, ATTR_BAG_ID, ATTR_DATATYPE, ATTR_ID, ATTR_NODE_ID, ATTR_PARSE_TYPE, ATTR_RESOURCE, ELT_ALT, ELT_BAG, ELT_DESCRIPTION, ELT_LI, ELT_RDF, ELT_SEQ, ELT_TYPE, KAONNS, PARSE_TYPE_COLLECTION, PARSE_TYPE_LITERAL, PARSE_TYPE_RESOURCE, RDF_ABOUT, RDF_BAG, RDF_DATATYPE, RDF_DESCRIPTION, RDF_FIRST, RDF_ID, RDF_LI, RDF_LIST, RDF_NIL, RDF_NODE_ID, RDF_OBJECT, RDF_PARSE_TYPE, RDF_PREDICATE, RDF_PROPERTY, RDF_RDF, RDF_RESOURCE, RDF_REST, RDF_STATEMENT, RDF_SUBJECT, RDF_TYPE, RDF_XMLLITERAL, RDFNS, RDFS_CLASS, RDFS_COMMENT, RDFS_DOMAIN, RDFS_LABEL, RDFS_RANGE, RDFS_SUBCLASSOF, RDFS_SUBPROPERTYOF, RDFSNS, XMLLANG, XMLNS
 
Constructor Summary
RDFParser()
          Creates a RDF parser.
 
Method Summary
 void characters(char[] data, int start, int length)
          Called when character content is parsed.
 void endDocument()
          Called when document parsing is ended.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          Called when element parsing is ended.
 void error(org.xml.sax.SAXParseException e)
          Called when error is encountered.
 void fatalError(org.xml.sax.SAXParseException e)
          Called when a fatal error is encountered.
 boolean isAnonymousNodeURI(java.lang.String uri)
          Tests whether supplied URI was generated by this parser in order to label an anonymous node.
 void parse(org.xml.sax.InputSource source, RDFConsumer consumer)
          Parses RDF from given input source.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Called when processing instruction is parsed.
 void setDocumentLocator(org.xml.sax.Locator locator)
          Called to receive a document locator.
 void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
          Sets the error handler.
 void startDocument()
          Called when document parsing is started.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          Called when an element is started.
 void warning(org.xml.sax.SAXParseException e)
          Called when warning is encountered.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, ignorableWhitespace, notationDecl, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RDFParser

public RDFParser()
Creates a RDF parser.

Method Detail

parse

public void parse(org.xml.sax.InputSource source,
                  RDFConsumer consumer)
           throws org.xml.sax.SAXException,
                  java.io.IOException
Parses RDF from given input source.

Parameters:
source - specifies where RDF comes from
consumer - receives notifications about RDF parsing events
Throws:
org.xml.sax.SAXException
java.io.IOException

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Called to receive a document locator.

Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
Parameters:
locator - the document locator

setErrorHandler

public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
Sets the error handler.

Parameters:
errorHandler - the error handler

warning

public void warning(org.xml.sax.SAXParseException e)
             throws org.xml.sax.SAXException
Called when warning is encountered.

Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - the exception
Throws:
org.xml.sax.SAXException

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
Called when error is encountered.

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - the exception
Throws:
org.xml.sax.SAXException

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
Called when a fatal error is encountered.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - the exception
Throws:
org.xml.sax.SAXException

startDocument

public void startDocument()
Called when document parsing is started.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Called when document parsing is ended.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Called when an element is started.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespaceURI - the URI of the namespace
localName - the local name of the element
qName - the Q-name of the element
atts - the attributes
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Called when element parsing is ended.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespaceURI - the URI of the namespace
localName - the local name of the element
qName - the Q-name of the element
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] data,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Called when character content is parsed.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
data - the data buffer containing the characters
start - the start index of character text
length - the length of the character text
Throws:
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Called when processing instruction is parsed.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Overrides:
processingInstruction in class org.xml.sax.helpers.DefaultHandler
Parameters:
target - the name of the processing instruction
data - the argument to the processing instruction
Throws:
org.xml.sax.SAXException

isAnonymousNodeURI

public boolean isAnonymousNodeURI(java.lang.String uri)
Tests whether supplied URI was generated by this parser in order to label an anonymous node.

Parameters:
uri - the URI
Returns:
true if the URI was generated by this parser to label an anonymous node