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 org.semanticweb.owlapi.model.IRI |
m_baseIRI
IRI of the document being parsed.
|
protected LinkedList<org.semanticweb.owlapi.model.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,org.semanticweb.owlapi.model.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) |
protected void |
checkUnsupportedAttributes(Attributes atts)
Checks if attribute list contains some of the unsupported attributes.
|
void |
endDocument() |
void |
endElement(String namespaceIRI,
String localName,
String qName) |
void |
error(SAXParseException e) |
void |
fatalError(SAXParseException e) |
protected String |
getIDNodeIDAboutResourceIRI(Attributes atts)
Extracts the IRI of the resource from rdf:ID, rdf:nodeID or rdf:about
attribute.
|
org.semanticweb.owlapi.model.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 |
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.
|
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.
|
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) |
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) |
void |
setErrorHandler(ErrorHandler errorHandler)
Sets the error handler.
|
void |
startDocument() |
void |
startElement(String namespaceIRI,
String localName,
String qName,
Attributes atts) |
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) |
endPrefixMapping, ignorableWhitespace, notationDecl, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDeclprotected static final Locator s_nullDocumentLocator
protected static final SAXParserFactory s_parserFactory
protected ErrorHandler m_errorHandler
protected LinkedList<org.semanticweb.owlapi.model.IRI> m_baseIRIs
protected org.semanticweb.owlapi.model.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 eventsSAXException - SAXExceptionIOException - IOExceptionpublic void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlersetDocumentLocator in class org.xml.sax.helpers.DefaultHandlerpublic void setErrorHandler(ErrorHandler errorHandler)
errorHandler - the error handlerpublic void warning(SAXParseException e) throws SAXException
warning in interface ErrorHandlerwarning in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic void error(SAXParseException e) throws SAXException
error in interface ErrorHandlererror in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic void fatalError(SAXParseException e) throws SAXException
fatalError in interface ErrorHandlerfatalError in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic 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.DefaultHandlerSAXExceptionpublic void endElement(String namespaceIRI, String localName, String qName) throws SAXException
endElement in interface ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic void characters(char[] data,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic void processingInstruction(String target, String data) throws SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in class org.xml.sax.helpers.DefaultHandlerSAXExceptionprotected void pushState(RDFParser.State state)
state - new stateprotected void popState()
throws SAXException
SAXException - SAXExceptionprotected void checkUnsupportedAttributes(Attributes atts) throws SAXException
atts - the attributesSAXException - SAXExceptionprotected void processXMLBase(Attributes atts) throws SAXException
atts - the attributes potentially containing xml:base declarationSAXException - SAXExceptionprotected void processXMLLanguage(Attributes atts)
atts - the attributes potentially containing xml:language declarationprotected String resolveIRI(String uri) throws SAXException
uri - the IRI being resolvedSAXException - SAXExceptionprotected String getIRIFromID(String id) throws SAXException
id - idSAXException - SAXExceptionprotected String getIRIFromAbout(String about) throws SAXException
about - aboutSAXException - SAXExceptionprotected String getIRIFromResource(String resource) throws SAXException
resource - resourceSAXException - SAXExceptionprotected String getIDNodeIDAboutResourceIRI(Attributes atts) throws SAXException
atts - attsSAXException - SAXExceptionprotected String getNodeIDResourceResourceIRI(Attributes atts) throws SAXException
null is returned.atts - the attributesnullSAXException - SAXExceptionprotected 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 statementSAXException - SAXExceptionprotected 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 statementSAXException - SAXExceptionprotected void propertyAttributes(String subjectIRI, Attributes atts, RDFParser.ReificationManager reificationManager) throws SAXException
subjectIRI - IRI of the resource whose properties are being parsedatts - attributesreificationManager - the reification managerSAXException - SAXExceptionprotected 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 attributesSAXException - SAXExceptionprotected 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 org.semanticweb.owlapi.model.IRI getIRI(String s)
s - stringCopyright © 2014 The University of Manchester. All Rights Reserved.