public class RDFParser extends org.xml.sax.helpers.DefaultHandler implements RDFConstants
| Modifier and Type | Class and Description |
|---|---|
protected class |
RDFParser.EmptyPropertyElement
Parses emptyPropertyElt production.
|
protected class |
RDFParser.NodeElement
Parses the nodeElement production.
|
protected class |
RDFParser.NodeElementList
Parses the nodeElementList production.
|
protected class |
RDFParser.ParseTypeCollectionPropertyElement
Parses parseTypeCollectionPropertyElt production.
|
protected class |
RDFParser.ParseTypeLiteralPropertyElement
Parses parseTypeLiteralPropertyElt production.
|
protected class |
RDFParser.ParseTypeResourcePropertyElement
Parses parseTypeResourcePropertyElt production.
|
protected class |
RDFParser.PropertyElementList
Parses the propertyEltList production.
|
protected static class |
RDFParser.ReificationManager |
protected class |
RDFParser.ReifiedStatementBag |
protected class |
RDFParser.ResourceOrLiteralPropertyElement
Parses resourcePropertyElt or literalPropertyElt productions.
|
protected class |
RDFParser.StartRDF
State expecting start of RDF text.
|
protected static class |
RDFParser.State
Base class for all parser states.
|
| Modifier and Type | Field and Description |
|---|---|
protected IRI |
m_baseIRI
IRI of the document being parsed.
|
protected LinkedList<IRI> |
m_baseIRIs
Stack of base IRIs.
|
protected RDFConsumer |
m_consumer
Consumer receiving notifications about parsing events.
|
protected Locator |
m_documentLocator
Document locator.
|
protected ErrorHandler |
m_errorHandler
Registered error handler.
|
protected String |
m_language
The current language.
|
protected LinkedList<String> |
m_languages
The stack of languages.
|
protected RDFParser.State |
m_state
Current parser's state.
|
protected List<RDFParser.State> |
m_states
Stack of parser states.
|
protected static Locator |
s_nullDocumentLocator |
protected static SAXParserFactory |
s_parserFactory |
protected Map<String,IRI> |
uriCache |
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 and Description |
|---|
RDFParser()
Creates a RDF parser.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] data,
int start,
int length)
Called when character content is parsed.
|
protected void |
checkUnsupportedAttributes(Attributes atts)
Checks if attribute list contains some of the unsupported attributes.
|
void |
endDocument()
Called when document parsing is ended.
|
void |
endElement(String namespaceIRI,
String localName,
String qName)
Called when element parsing is ended.
|
void |
error(SAXParseException e)
Called when error is encountered.
|
void |
fatalError(SAXParseException e)
Called when a fatal error is encountered.
|
protected String |
getIDNodeIDAboutResourceIRI(Attributes atts)
Extracts the IRI of the resource from rdf:ID, rdf:nodeID or rdf:about attribute.
|
IRI |
getIRI(String s) |
protected String |
getIRIFromAbout(String about)
Returns an absolute IRI from an about attribute.
|
protected String |
getIRIFromID(String id)
Returns an absolute IRI from an ID.
|
protected String |
getIRIFromNodeID(String nodeID)
Returns an abolute IRI from a nodeID attribute.
|
protected String |
getIRIFromResource(String resource)
Returns an absolute IRI from a resource attribute.
|
protected String |
getNodeIDResourceResourceIRI(Attributes atts)
Extracts the IRI of the resource from rdf:resource or rdf:nodeID attribute.
|
protected RDFParser.ReificationManager |
getReificationManager(Attributes atts)
Returns the reification manager for given attributes.
|
boolean |
isAnonymousNodeID(String iri) |
boolean |
isAnonymousNodeIRI(String uri)
Tests whether supplied IRI was generated by this parser in order to label an anonymous node.
|
protected boolean |
isWhitespaceOnly(char[] data,
int start,
int length)
Checks whether given characters contain only whitespace.
|
protected boolean |
isWhitespaceOnly(StringBuilder buffer)
Checks whether given characters contain only whitespace.
|
protected String |
nextAnonymousIRI()
Generates next anonymous IRI.
|
void |
parse(InputSource source,
RDFConsumer consumer)
Parses RDF from given input source.
|
protected Map<String,String> |
parseStringArguments(String string)
Parses the string into a map of name-value pairs.
|
protected void |
popState()
Pops a state from the stack.
|
void |
processingInstruction(String target,
String data)
Called when processing instruction is parsed.
|
protected void |
processXMLBase(Attributes atts)
Processes xml:base reference if there is one.
|
protected void |
processXMLLanguage(Attributes atts)
Processes xml:language reference is there is one.
|
protected void |
propertyAttributes(String subjectIRI,
Attributes atts,
RDFParser.ReificationManager reificationManager)
Parses the propertyAttributes production.
|
protected void |
pushState(RDFParser.State state)
Pushes a new state on the state stack.
|
protected String |
resolveIRI(String uri)
Resolves an IRI with the current base.
|
void |
setDocumentLocator(Locator locator)
Called to receive a document locator.
|
void |
setErrorHandler(ErrorHandler errorHandler)
Sets the error handler.
|
void |
startDocument()
Called when document parsing is started.
|
void |
startElement(String namespaceIRI,
String localName,
String qName,
Attributes atts)
Called when an element is started.
|
protected void |
statementWithLiteralValue(String subject,
String predicate,
String object,
String dataType,
String reificationID)
Called when a statement with literal value is added to the model.
|
protected void |
statementWithResourceValue(String subject,
String predicate,
String object,
String reificationID)
Called when a statement with resource value is added to the model.
|
void |
warning(SAXParseException e)
Called when warning is encountered.
|
endPrefixMapping, ignorableWhitespace, notationDecl, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDeclprotected static final Locator s_nullDocumentLocator
protected static final SAXParserFactory s_parserFactory
protected ErrorHandler m_errorHandler
protected LinkedList<IRI> m_baseIRIs
protected IRI m_baseIRI
protected LinkedList<String> m_languages
protected String m_language
protected RDFConsumer m_consumer
protected RDFParser.State m_state
protected List<RDFParser.State> m_states
protected Locator m_documentLocator
public void parse(InputSource source, RDFConsumer consumer) throws SAXException, IOException
source - specifies where RDF comes fromconsumer - receives notifications about RDF parsing eventsSAXExceptionIOExceptionpublic void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlersetDocumentLocator in class org.xml.sax.helpers.DefaultHandlerlocator - the document locatorpublic void setErrorHandler(ErrorHandler errorHandler)
errorHandler - the error handlerpublic void warning(SAXParseException e) throws SAXException
warning in interface ErrorHandlerwarning in class org.xml.sax.helpers.DefaultHandlere - the exceptionSAXExceptionpublic void error(SAXParseException e) throws SAXException
error in interface ErrorHandlererror in class org.xml.sax.helpers.DefaultHandlere - the exceptionSAXExceptionpublic void fatalError(SAXParseException e) throws SAXException
fatalError in interface ErrorHandlerfatalError in class org.xml.sax.helpers.DefaultHandlere - the exceptionSAXExceptionpublic void startDocument()
startDocument in interface ContentHandlerstartDocument in class org.xml.sax.helpers.DefaultHandlerpublic void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic void startElement(String namespaceIRI, String localName, String qName, Attributes atts) throws SAXException
startElement in interface ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlernamespaceIRI - the IRI of the namespacelocalName - the local name of the elementqName - the Q-name of the elementatts - the attributesSAXExceptionpublic void endElement(String namespaceIRI, String localName, String qName) throws SAXException
endElement in interface ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlernamespaceIRI - the IRI of the namespacelocalName - the local name of the elementqName - the Q-name of the elementSAXExceptionpublic void characters(char[] data,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerdata - the data buffer containing the charactersstart - the start index of character textlength - the length of the character textSAXExceptionpublic void processingInstruction(String target, String data) throws SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in class org.xml.sax.helpers.DefaultHandlertarget - the name of the processing instructiondata - the argument to the processing instructionSAXExceptionprotected void pushState(RDFParser.State state)
state - new stateprotected void popState()
throws SAXException
SAXExceptionprotected void checkUnsupportedAttributes(Attributes atts) throws SAXException
atts - the attributesSAXExceptionprotected void processXMLBase(Attributes atts) throws SAXException
atts - the attributes potentially containing xml:base declarationSAXExceptionprotected void processXMLLanguage(Attributes atts)
atts - the attributes potentially containing xml:language declarationprotected String resolveIRI(String uri) throws SAXException
uri - the IRI being resolvedSAXExceptionprotected String getIRIFromID(String id) throws SAXException
SAXExceptionprotected String getIRIFromAbout(String about) throws SAXException
SAXExceptionprotected String getIRIFromNodeID(String nodeID) throws SAXException
SAXExceptionprotected String getIRIFromResource(String resource) throws SAXException
SAXExceptionprotected String nextAnonymousIRI() throws SAXException
SAXExceptionprotected String getIDNodeIDAboutResourceIRI(Attributes atts) throws SAXException
SAXExceptionprotected String getNodeIDResourceResourceIRI(Attributes atts) throws SAXException
null is returned.atts - the attributesnullSAXExceptionprotected void statementWithResourceValue(String subject, String predicate, String object, String reificationID) throws SAXException
subject - IRI of the subject resourcepredicate - IRI of the predicate resourceobject - IRI of the object resourcereificationID - if not null, contains IRI of the resource that will wold the reified statementSAXExceptionprotected void statementWithLiteralValue(String subject, String predicate, String object, String dataType, String reificationID) throws SAXException
subject - IRI of the subject resourcepredicate - IRI of the predicate resourceobject - literal object valuedataType - the IRI of the literal's datatype (may be null)reificationID - if not null, contains IRI of the resource that will wold the reified statementSAXExceptionprotected void propertyAttributes(String subjectIRI, Attributes atts, RDFParser.ReificationManager reificationManager) throws SAXException
subjectIRI - IRI of the resource whose properties are being parsedatts - attributesreificationManager - the reification managerSAXExceptionprotected boolean isWhitespaceOnly(char[] data,
int start,
int length)
data - the data being checkedstart - the start index (inclusive)length - the end index (non-inclusive)true if characters contain whitespaceprotected boolean isWhitespaceOnly(StringBuilder buffer)
buffer - the data being checkedtrue if characters contain whitespaceprotected RDFParser.ReificationManager getReificationManager(Attributes atts) throws SAXException
atts - the attributesSAXExceptionprotected Map<String,String> parseStringArguments(String string) throws SAXException
string - string to be parsedSAXException - if there was an IOException this will be wrapped in a parse exceptionpublic boolean isAnonymousNodeIRI(String uri)
uri - the IRItrue if the IRI was generated by this parser to label an anonymous nodepublic boolean isAnonymousNodeID(String iri)
Copyright © 2012 The University of Manchester. All Rights Reserved.