public class RDFParser extends DefaultHandler implements IRIProvider
Constructor and Description |
---|
RDFParser() |
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length) |
void |
endDocument() |
void |
endElement(String uri,
String localName,
String qName) |
void |
error(SAXParseException e) |
void |
fatalError(SAXParseException e) |
IRI |
getIRI(String s) |
void |
parse(InputSource source,
RDFConsumer inputConsumer)
Parses RDF from given input source.
|
void |
popState()
Pops a state from the stack.
|
void |
processingInstruction(String target,
String data) |
void |
pushState(State s)
Pushes a new state on the state stack.
|
String |
resolveIRI(String iri)
Resolves an IRI with the current base.
|
void |
setDocumentLocator(Locator locator) |
void |
setErrorHandler(ErrorHandler errorHandler)
Sets the error handler.
|
void |
startDocument() |
void |
startElement(String uri,
String localName,
String qName,
Attributes attributes) |
void |
statementWithLiteralValue(String subject,
String predicate,
String object,
String dataType,
String reificationID)
Called when a statement with literal value is added to the model.
|
void |
statementWithResourceValue(String subject,
String predicate,
String object,
String reificationID)
Called when a statement with resource value is added to the model.
|
void |
verify(boolean b,
String message)
If condition b is true, throw an exception with provided message
|
void |
warning(SAXParseException e) |
endPrefixMapping, ignorableWhitespace, notationDecl, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
public void parse(@Nonnull InputSource source, @Nonnull RDFConsumer inputConsumer) throws SAXException, IOException
source
- specifies where RDF comes frominputConsumer
- receives notifications about RDF parsing eventsSAXException
- SAX exceptionIOException
- if there was a problem parsing the output streampublic void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
setDocumentLocator
in class DefaultHandler
public void setErrorHandler(@Nonnull ErrorHandler errorHandler)
errorHandler
- the error handlerpublic void warning(SAXParseException e) throws SAXException
warning
in interface ErrorHandler
warning
in class DefaultHandler
SAXException
public void error(SAXParseException e) throws SAXException
error
in interface ErrorHandler
error
in class DefaultHandler
SAXException
public void fatalError(SAXParseException e) throws SAXException
fatalError
in interface ErrorHandler
fatalError
in class DefaultHandler
SAXException
public void startDocument()
startDocument
in interface ContentHandler
startDocument
in class DefaultHandler
public void endDocument()
endDocument
in interface ContentHandler
endDocument
in class DefaultHandler
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
startElement
in interface ContentHandler
startElement
in class DefaultHandler
SAXException
public void endElement(String uri, String localName, String qName) throws SAXException
endElement
in interface ContentHandler
endElement
in class DefaultHandler
SAXException
public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
characters
in class DefaultHandler
SAXException
public void processingInstruction(String target, String data)
processingInstruction
in interface ContentHandler
processingInstruction
in class DefaultHandler
public void pushState(State s)
s
- new statepublic void popState()
@Nonnull public String resolveIRI(@Nonnull String iri)
iri
- the IRI being resolvedpublic void statementWithResourceValue(@Nonnull String subject, @Nonnull String predicate, @Nonnull String object, @Nullable String reificationID)
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 hold the
reified statementpublic void statementWithLiteralValue(@Nonnull String subject, @Nonnull String predicate, @Nonnull String object, @Nullable String dataType, @Nullable String reificationID)
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 hold the
reified statement@Nonnull public IRI getIRI(@Nonnull String s)
getIRI
in interface IRIProvider
s
- input Stringpublic void verify(boolean b, @Nonnull String message)
b
- condition to verifymessage
- message for the exceptionRDFParserException
- exception thrownCopyright © 2020 The University of Manchester. All rights reserved.