|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
org.semanticweb.owlapi.rdf.syntax.RDFParser
public class RDFParser
This class parses the RDF according to the syntax specified in http://www.w3.org/TR/rdf-syntax-grammar/.
Nested Class Summary | |
---|---|
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. |
Field Summary | |
---|---|
protected IRI |
m_baseIRI
IRI of the document being parsed. |
protected java.util.LinkedList<IRI> |
m_baseIRIs
Stack of base IRIs. |
protected RDFConsumer |
m_consumer
Consumer receiving notifications about parsing events. |
protected org.xml.sax.Locator |
m_documentLocator
Document locator. |
protected org.xml.sax.ErrorHandler |
m_errorHandler
Registered error handler. |
protected int |
m_generatedIRIIndex
Number of the last generated IRI. |
protected java.lang.String |
m_language
The current language. |
protected java.util.LinkedList<java.lang.String> |
m_languages
The stack of languages. |
protected RDFParser.State |
m_state
Current parser's state. |
protected java.util.List<RDFParser.State> |
m_states
Stack of parser states. |
protected static org.xml.sax.Locator |
s_nullDocumentLocator
|
protected static javax.xml.parsers.SAXParserFactory |
s_parserFactory
|
protected java.util.Map<java.lang.String,IRI> |
uriCache
|
Fields inherited from interface org.semanticweb.owlapi.rdf.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. |
protected void |
checkUnsupportedAttributes(org.xml.sax.Attributes atts)
Checks if attribute list contains some of the unsupported attributes. |
void |
endDocument()
Called when document parsing is ended. |
void |
endElement(java.lang.String namespaceIRI,
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. |
protected java.lang.String |
getIDNodeIDAboutResourceIRI(org.xml.sax.Attributes atts)
Extracts the IRI of the resource from rdf:ID, rdf:nodeID or rdf:about attribute. |
IRI |
getIRI(java.lang.String s)
|
protected java.lang.String |
getIRIFromAbout(java.lang.String about)
Returns an absolute IRI from an about attribute. |
protected java.lang.String |
getIRIFromID(java.lang.String id)
Returns an absolute IRI from an ID. |
protected java.lang.String |
getIRIFromNodeID(java.lang.String nodeID)
Returns an abolute IRI from a nodeID attribute. |
protected java.lang.String |
getIRIFromResource(java.lang.String resource)
Returns an absolute IRI from a resource attribute. |
protected java.lang.String |
getNodeIDResourceResourceIRI(org.xml.sax.Attributes atts)
Extracts the IRI of the resource from rdf:resource or rdf:nodeID attribute. |
protected RDFParser.ReificationManager |
getReificationManager(org.xml.sax.Attributes atts)
Returns the reification manager for given attributes. |
boolean |
isAnonymousNodeID(java.lang.String iri)
|
boolean |
isAnonymousNodeIRI(java.lang.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(java.lang.StringBuilder buffer)
Checks whether given characters contain only whitespace. |
protected java.lang.String |
nextAnonymousIRI()
Generates next anonymous IRI. |
void |
parse(org.xml.sax.InputSource source,
RDFConsumer consumer)
Parses RDF from given input source. |
protected java.util.Map |
parseStringArguments(java.lang.String string)
Parses the string into a map of name-value pairs. |
protected void |
popState()
Pops a state from the stack. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Called when processing instruction is parsed. |
protected void |
processXMLBase(org.xml.sax.Attributes atts)
Processes xml:base reference if there is one. |
protected void |
processXMLLanguage(org.xml.sax.Attributes atts)
Processes xml:language reference is there is one. |
protected void |
propertyAttributes(java.lang.String subjectIRI,
org.xml.sax.Attributes atts,
RDFParser.ReificationManager reificationManager)
Parses the propertyAttributes production. |
protected void |
pushState(RDFParser.State state)
Pushes a new state on the state stack. |
protected java.lang.String |
resolveIRI(java.lang.String uri)
Resolves an IRI with the current base. |
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 namespaceIRI,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
Called when an element is started. |
protected void |
statementWithLiteralValue(java.lang.String subject,
java.lang.String predicate,
java.lang.String object,
java.lang.String dataType,
java.lang.String reificationID)
Called when a statement with literal value is added to the model. |
protected void |
statementWithResourceValue(java.lang.String subject,
java.lang.String predicate,
java.lang.String object,
java.lang.String reificationID)
Called when a statement with resource value is added to the model. |
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 |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.xml.sax.Locator s_nullDocumentLocator
protected static final javax.xml.parsers.SAXParserFactory s_parserFactory
protected java.util.Map<java.lang.String,IRI> uriCache
protected org.xml.sax.ErrorHandler m_errorHandler
protected java.util.LinkedList<IRI> m_baseIRIs
protected IRI m_baseIRI
protected java.util.LinkedList<java.lang.String> m_languages
protected java.lang.String m_language
protected RDFConsumer m_consumer
protected RDFParser.State m_state
protected java.util.List<RDFParser.State> m_states
protected int m_generatedIRIIndex
protected org.xml.sax.Locator m_documentLocator
Constructor Detail |
---|
public RDFParser()
Method Detail |
---|
public void parse(org.xml.sax.InputSource source, RDFConsumer consumer) throws org.xml.sax.SAXException, java.io.IOException
source
- specifies where RDF comes fromconsumer
- receives notifications about RDF parsing events
org.xml.sax.SAXException
java.io.IOException
public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator
in interface org.xml.sax.ContentHandler
setDocumentLocator
in class org.xml.sax.helpers.DefaultHandler
locator
- the document locatorpublic void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
errorHandler
- the error handlerpublic void warning(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
warning
in interface org.xml.sax.ErrorHandler
warning
in class org.xml.sax.helpers.DefaultHandler
e
- the exception
org.xml.sax.SAXException
public void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
error
in interface org.xml.sax.ErrorHandler
error
in class org.xml.sax.helpers.DefaultHandler
e
- the exception
org.xml.sax.SAXException
public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
fatalError
in interface org.xml.sax.ErrorHandler
fatalError
in class org.xml.sax.helpers.DefaultHandler
e
- the exception
org.xml.sax.SAXException
public void startDocument()
startDocument
in interface org.xml.sax.ContentHandler
startDocument
in class org.xml.sax.helpers.DefaultHandler
public void endDocument() throws org.xml.sax.SAXException
endDocument
in interface org.xml.sax.ContentHandler
endDocument
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void startElement(java.lang.String namespaceIRI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
namespaceIRI
- the IRI of the namespacelocalName
- the local name of the elementqName
- the Q-name of the elementatts
- the attributes
org.xml.sax.SAXException
public void endElement(java.lang.String namespaceIRI, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
namespaceIRI
- the IRI of the namespacelocalName
- the local name of the elementqName
- the Q-name of the element
org.xml.sax.SAXException
public void characters(char[] data, int start, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
data
- the data buffer containing the charactersstart
- the start index of character textlength
- the length of the character text
org.xml.sax.SAXException
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
processingInstruction
in interface org.xml.sax.ContentHandler
processingInstruction
in class org.xml.sax.helpers.DefaultHandler
target
- the name of the processing instructiondata
- the argument to the processing instruction
org.xml.sax.SAXException
protected void pushState(RDFParser.State state)
state
- new stateprotected void popState() throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void checkUnsupportedAttributes(org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
atts
- the attributes
org.xml.sax.SAXException
protected void processXMLBase(org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
atts
- the attributes potentially containing xml:base declaration
org.xml.sax.SAXException
protected void processXMLLanguage(org.xml.sax.Attributes atts)
atts
- the attributes potentially containing xml:language declarationprotected java.lang.String resolveIRI(java.lang.String uri) throws org.xml.sax.SAXException
uri
- the IRI being resolved
org.xml.sax.SAXException
protected java.lang.String getIRIFromID(java.lang.String id) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected java.lang.String getIRIFromAbout(java.lang.String about) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected java.lang.String getIRIFromNodeID(java.lang.String nodeID) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected java.lang.String getIRIFromResource(java.lang.String resource) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected java.lang.String nextAnonymousIRI() throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected java.lang.String getIDNodeIDAboutResourceIRI(org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected java.lang.String getNodeIDResourceResourceIRI(org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
null
is returned.
atts
- the attributes
null
org.xml.sax.SAXException
protected void statementWithResourceValue(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String reificationID) throws org.xml.sax.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 statement
org.xml.sax.SAXException
protected void statementWithLiteralValue(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String dataType, java.lang.String reificationID) throws org.xml.sax.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 statement
org.xml.sax.SAXException
protected void propertyAttributes(java.lang.String subjectIRI, org.xml.sax.Attributes atts, RDFParser.ReificationManager reificationManager) throws org.xml.sax.SAXException
subjectIRI
- IRI of the resource whose properties are being parsedatts
- attributesreificationManager
- the reification manager
org.xml.sax.SAXException
protected 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(java.lang.StringBuilder buffer)
buffer
- the data being checked
true
if characters contain whitespaceprotected RDFParser.ReificationManager getReificationManager(org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
atts
- the attributes
org.xml.sax.SAXException
protected java.util.Map parseStringArguments(java.lang.String string) throws org.xml.sax.SAXException
string
- string to be parsed
org.xml.sax.SAXException
- if there was an IOException this will be wrapped in a parse exceptionpublic boolean isAnonymousNodeIRI(java.lang.String uri)
uri
- the IRI
true
if the IRI was generated by this parser to label an anonymous nodepublic boolean isAnonymousNodeID(java.lang.String iri)
public IRI getIRI(java.lang.String s)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |