TResult - the type of the result provided by this parserTDataProvider - the type of the IDataProviderTElementCreator - the type of the IElementCreator @author Xyanid on 24.10.2015.public abstract class SAXParser<TResult,TDataProvider extends IDataProvider,TElementCreator extends IElementCreator<TDataProvider,TElement>,TElement extends ElementBase<TDataProvider,?,TElement>> extends org.xml.sax.helpers.DefaultHandler
| Type | Property and Description |
|---|---|
javafx.beans.property.ReadOnlyProperty<SAXParser.State> |
state
Gets the property State.
|
| Modifier and Type | Class and Description |
|---|---|
static class |
SAXParser.State
Determines in which state the converter is in.
|
| Constructor and Description |
|---|
SAXParser(TElementCreator elementCreator,
TDataProvider dataProvider)
Creates a new instance of the parser using the provided interfaces.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int start,
int length) |
void |
clear()
This method will clear the current
result as well as calling IDataProvider.clear(). |
protected abstract void |
consumeElementEnd(TResult result,
TDataProvider dataProvider,
TElement element)
This method will be called when an element has ended in the XML tree.
|
protected abstract void |
consumeElementStart(TResult result,
TDataProvider dataProvider,
TElement element)
This method will be called when a new element is starting in the XML tree.
|
void |
endDocument() |
void |
endElement(String namespaceURI,
String localName,
String qName) |
protected abstract TResult |
enteringDocument()
This method will be called as soon as the parsing of the document has started and set the current
result. |
long |
getAttemptedParses()
gets the
attemptedParses. |
TResult |
getResult()
Gets the
result, which is only set after parse(InputSource) has been called. |
SAXParser.State |
getState()
Gets the value of the State.
|
long |
getSuccessfulParses()
gets the
successfulParses. |
boolean |
isBusy()
Determines if the parser is busy doing its work, this is the case if the state is not IDLE or FINISHED.
|
protected abstract void |
leavingDocument(TResult result)
This method will be called as soon as the parsing of the document has been finished, the current
result
will be be provided so final operation can be performed. |
void |
parse(File file)
Parses the data of the given file.
|
void |
parse(InputSource data)
Parse the data of the given input source.
|
void |
parse(String path)
Parses the data of the file provided by the given path.
|
void |
setSuccessfulParses(long value)
sets the
successfulParses. |
void |
startDocument() |
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes attributes) |
javafx.beans.property.ReadOnlyProperty<SAXParser.State> |
stateProperty()
Gets the property State.
|
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warningpublic final javafx.beans.property.ReadOnlyProperty<SAXParser.State> stateProperty
public SAXParser(TElementCreator elementCreator, TDataProvider dataProvider) throws IllegalArgumentException
elementCreator - element creator to be useddataProvider - data provider to be usedIllegalArgumentException - if either elementCreator or dataProvider are nullpublic final TResult getResult()
result, which is only set after parse(InputSource) has been called.resultpublic final long getAttemptedParses()
attemptedParses.attemptedParsespublic final long getSuccessfulParses()
successfulParses.successfulParsespublic final void setSuccessfulParses(long value)
successfulParses.value - value to be used for successfulParsespublic final SAXParser.State getState()
public final boolean isBusy()
protected abstract TResult enteringDocument() throws SAXException
result.
Ideally a new result will be initialized here so it can be filled when the document is processed.result.SAXException - when an error occursprotected abstract void leavingDocument(TResult result) throws SAXException
result
will be be provided so final operation can be performed.result - the current result, which was initialized during enteringDocument().SAXException - when an error occursprotected abstract void consumeElementStart(TResult result, TDataProvider dataProvider, TElement element) throws SAXException
result.result - the current result, which was initialized during enteringDocument().dataProvider - the dataProvider that as provided during initializationelement - element to be consumedSAXException - when an error occursprotected abstract void consumeElementEnd(TResult result, TDataProvider dataProvider, TElement element) throws SAXException
result - the current result, which was initialized during enteringDocument().dataProvider - the dataProvider that as provided during initialization.element - element to be consumed.SAXException - when an error occurspublic final javafx.beans.property.ReadOnlyProperty<SAXParser.State> stateProperty()
public final void clear()
result as well as calling IDataProvider.clear().public final void parse(String path) throws SAXParseException, IllegalArgumentException, IllegalStateException, IOException
path - path of the file to be usedSAXParseException - if an exception occurs while parsing the dataIllegalArgumentException - if the given file is nullIllegalStateException - if this method is being called while the parser is still busyIOException - if the file can not be found or openedpublic final void parse(File file) throws SAXParseException, IllegalArgumentException, IllegalStateException, IOException
file - file to be usedSAXParseException - if an exception occurs while parsing the dataIllegalArgumentException - if the given file is nullIllegalStateException - if this method is being called while the parser is still busyIOException - if the file can not be found or openedpublic final void parse(InputSource data) throws SAXParseException, IllegalArgumentException, IllegalStateException
data - data to be used, must not be nullSAXParseException - if an exception occurs while parsing the dataIllegalArgumentException - if the given data is nullIllegalStateException - if this method is being called while the parser is still busypublic final void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic final void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic final void startElement(String namespaceURI, String localName, String qName, Attributes attributes) throws SAXException
startElement in interface ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic final void endElement(String namespaceURI, String localName, String qName) throws SAXException
endElement in interface ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic final void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerSAXExceptionCopyright © 2016 Saxonia Systems AG. All rights reserved.