Class SAXEventQueue
- All Implemented Interfaces:
SAXEventStream,ContentHandler,ErrorHandler,LexicalHandler
It acts passively on both sides:
For receiving, it implements
ContentHandler (for receiving open tags, close tags, character data
and processing instructions),
LexicalHandler (for receiving comments), and
ErrorHandler.On the consumer side it implements
SAXEventStream, which must be actively
polled by a consumer process, and supports to set a ErrorHandler,
to which the incoming errors are transparently propagated.
ATTENTION There is a constructor with and one without
(final, not initial!) capacity. The first creates an
ArrayBlockingQueue,
the other a
LinkedBlockingQueue.
Originally, this class was intended for realizing a "buffered pipe"
between a producer and a consumer running in two different threads.
The producer uses the ContentHandler interface,
the consumer the SAXEventStream interface.
It has successfully been "abused" also as a storage for SAX events,
ie. producer and consumer running in the same thread, subsequently.
Then the accumulated contents is sent to the consumer by a call
to drainTo().
In this case it must be well observed that only the LinkedBlockingQueue
will expand automatically.
Choosing the ArrayBlockingQueue with too small a capacity will hang the
producer process!
-
Nested Class Summary
Nested classes/interfaces inherited from interface eu.bandm.tools.util2.SAXEventStream
SAXEventStream.EtherealMatcher, SAXEventStream.MatchException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) @Opt XMLDocumentIdentifier_getDocumentId(eu.bandm.tools.util2.SAXEventQueue.Item item) voidcharacters(char[] data, int offset, int length) voidclear()FIXME benötigt??voidcomment(char[] ch, int start, int length) final voidconsume()Must only be called after (at least) one invocation oflookahead().Consumes any chararcter data event, and returns the data.voidVisits all ethereals which have been colleced immediately PRECEDING the last consumed event (start tag/end tag/char data/end of document) Visit them in source text order (=reverse order of the linked list).voiddrainTo(ContentHandler drain) voiddump(PrintStream os) voidendCDATA()voidWrite the last tag (a close tag) to the queue, because now it must have all its Ethereals.voidendDTD()voidendElement(String uri, String name, String qName) voidvoidendPrefixMapping(String prefix) voidvoidCHECK FIXME ist das wirklich "public" notwendig?Returns the local name of the current head, i.e.Delivers the location of the current NEXT Event, i.e.Returns the namespace name of the current head, i.e.Returns the namespace URI of the current head, i.e.Returns the qualified name of the current head, i.e.Returns the conventional textual representation of the current head.voidignorableWhitespace(char[] data, int offset, int length) booleanReturns whether the next SAX event represents character data.booleanReturns whether the next SAX event is the "End of Document" element.booleanReturns whether the next SAX event is any end element event (= close element tag)booleanReturns whether the next SAX event is a certain end element event (= close element tag)booleanlookaheadEndElement(String qname) Returns whether the next SAX event is a certain end element event (= close element tag)booleanReturns whether the next SAX event is any start element event (= open element tag)booleanReturns whether the next SAX event is a certain start element event (= open element tag)booleanlookaheadStartElement(String qname) Returns whether the next SAX event is a certain start element event (= open element tag)voidConsumes the first element (if it is the indicated end document element).voidmatchEndElement(NamespaceName name) Consumes the first element (if it is the indicated end element).voidmatchEndElement(String name) Consumes the first element (if it is the indicated end element).Consumes the first element (if it is the indicated start element) and returns its attribute set.matchStartElement(String qname) Consumes the first element (if it is the indicated start element) and returns its attribute set.voidprocessingInstruction(String target, String body) protected voidvoidsetDocumentLocator(Locator locator) voidsetErrorHandler(ErrorHandler errorHandler) voidsink()FIXME DOKU WAS SOLL DAS ?voidskippedEntity(String name) voidvoidvoidvoidstartElement(String uri, String name, String qName, Attributes atts) voidstartEntity(String name) voidstartPrefixMapping(String prefix, String uri) voidprotected voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
SAXEventQueue
public SAXEventQueue() -
SAXEventQueue
public SAXEventQueue(int size)
-
-
Method Details
-
setErrorHandler
-
getErrorHandler
-
clear
public void clear()FIXME benötigt?? -
sink
public void sink()FIXME DOKU WAS SOLL DAS ? -
dump
-
readInterrupted
protected void readInterrupted() -
writeInterrupted
protected void writeInterrupted() -
characters
public void characters(char[] data, int offset, int length) - Specified by:
charactersin interfaceContentHandler
-
startDocument
public void startDocument()- Specified by:
startDocumentin interfaceContentHandler
-
endDocument
public void endDocument()Write the last tag (a close tag) to the queue, because now it must have all its Ethereals.- Specified by:
endDocumentin interfaceContentHandler
-
startPrefixMapping
- Specified by:
startPrefixMappingin interfaceContentHandler
-
endPrefixMapping
- Specified by:
endPrefixMappingin interfaceContentHandler
-
ignorableWhitespace
public void ignorableWhitespace(char[] data, int offset, int length) - Specified by:
ignorableWhitespacein interfaceContentHandler
-
processingInstruction
- Specified by:
processingInstructionin interfaceContentHandler
-
skippedEntity
- Specified by:
skippedEntityin interfaceContentHandler
-
setDocumentLocator
- Specified by:
setDocumentLocatorin interfaceContentHandler
-
startElement
- Specified by:
startElementin interfaceContentHandler
-
endElement
- Specified by:
endElementin interfaceContentHandler
-
comment
public void comment(char[] ch, int start, int length) - Specified by:
commentin interfaceLexicalHandler
-
endCDATA
public void endCDATA()- Specified by:
endCDATAin interfaceLexicalHandler
-
endDTD
public void endDTD()- Specified by:
endDTDin interfaceLexicalHandler
-
endEntity
- Specified by:
endEntityin interfaceLexicalHandler
-
startCDATA
public void startCDATA()- Specified by:
startCDATAin interfaceLexicalHandler
-
startDTD
- Specified by:
startDTDin interfaceLexicalHandler
-
startEntity
- Specified by:
startEntityin interfaceLexicalHandler
-
warning
- Specified by:
warningin interfaceErrorHandler- Throws:
SAXException
-
error
- Specified by:
errorin interfaceErrorHandler- Throws:
SAXException
-
fatalError
- Specified by:
fatalErrorin interfaceErrorHandler- Throws:
SAXException
-
lookaheadCharacters
public boolean lookaheadCharacters()Description copied from interface:SAXEventStreamReturns whether the next SAX event represents character data.- Specified by:
lookaheadCharactersin interfaceSAXEventStream
-
lookaheadStartElement
Description copied from interface:SAXEventStreamReturns whether the next SAX event is a certain start element event (= open element tag)- Specified by:
lookaheadStartElementin interfaceSAXEventStream
-
lookaheadStartElement
Description copied from interface:SAXEventStreamReturns whether the next SAX event is a certain start element event (= open element tag)- Specified by:
lookaheadStartElementin interfaceSAXEventStream
-
lookaheadStartElement
public boolean lookaheadStartElement()Description copied from interface:SAXEventStreamReturns whether the next SAX event is any start element event (= open element tag)- Specified by:
lookaheadStartElementin interfaceSAXEventStream
-
matchStartElement
Description copied from interface:SAXEventStreamConsumes the first element (if it is the indicated start element) and returns its attribute set.- Specified by:
matchStartElementin interfaceSAXEventStream- Throws:
SAXEventStream.MatchException
-
matchStartElement
Description copied from interface:SAXEventStreamConsumes the first element (if it is the indicated start element) and returns its attribute set.- Specified by:
matchStartElementin interfaceSAXEventStream- Throws:
SAXEventStream.MatchException
-
lookaheadEndElement
Description copied from interface:SAXEventStreamReturns whether the next SAX event is a certain end element event (= close element tag)- Specified by:
lookaheadEndElementin interfaceSAXEventStream
-
lookaheadEndElement
Description copied from interface:SAXEventStreamReturns whether the next SAX event is a certain end element event (= close element tag)- Specified by:
lookaheadEndElementin interfaceSAXEventStream
-
lookaheadEndElement
public boolean lookaheadEndElement()Description copied from interface:SAXEventStreamReturns whether the next SAX event is any end element event (= close element tag)- Specified by:
lookaheadEndElementin interfaceSAXEventStream
-
matchEndElement
Description copied from interface:SAXEventStreamConsumes the first element (if it is the indicated end element).- Specified by:
matchEndElementin interfaceSAXEventStream- Throws:
SAXEventStream.MatchException
-
matchEndElement
Description copied from interface:SAXEventStreamConsumes the first element (if it is the indicated end element).- Specified by:
matchEndElementin interfaceSAXEventStream- Throws:
SAXEventStream.MatchException
-
lookaheadEndDocument
public boolean lookaheadEndDocument()Description copied from interface:SAXEventStreamReturns whether the next SAX event is the "End of Document" element.- Specified by:
lookaheadEndDocumentin interfaceSAXEventStream
-
matchEndDocument
Description copied from interface:SAXEventStreamConsumes the first element (if it is the indicated end document element).- Specified by:
matchEndDocumentin interfaceSAXEventStream- Throws:
SAXEventStream.MatchException
-
consumeCharacters
Description copied from interface:SAXEventStreamConsumes any chararcter data event, and returns the data.- Specified by:
consumeCharactersin interfaceSAXEventStream
-
getAttributes
-
getNamespaceURI
Description copied from interface:SAXEventStreamReturns the namespace URI of the current head, i.e. the next element to consume.- Specified by:
getNamespaceURIin interfaceSAXEventStream
-
getLocalName
Description copied from interface:SAXEventStreamReturns the local name of the current head, i.e. the next element to consume.- Specified by:
getLocalNamein interfaceSAXEventStream
-
getQualifiedName
Description copied from interface:SAXEventStreamReturns the qualified name of the current head, i.e. the next element to consume.- Specified by:
getQualifiedNamein interfaceSAXEventStream
-
getNamespaceName
Description copied from interface:SAXEventStreamReturns the namespace name of the current head, i.e. the next element to consume.- Specified by:
getNamespaceNamein interfaceSAXEventStream
-
consume
public final void consume()Must only be called after (at least) one invocation oflookahead(). Afterwards,lookahead()may may block again. GLO OUT consumedEthereals- Specified by:
consumein interfaceSAXEventStream
-
consumedEthereals
Visits all ethereals which have been colleced immediately PRECEDING the last consumed event (start tag/end tag/char data/end of document) Visit them in source text order (=reverse order of the linked list).- Specified by:
consumedEtherealsin interfaceSAXEventStream
-
matchedEtherealLocation
- Specified by:
matchedEtherealLocationin interfaceSAXEventStream
-
getDocumentId
CHECK FIXME ist das wirklich "public" notwendig? -
_getDocumentId
-
getLocation
Delivers the location of the current NEXT Event, i.e. the event which will be considered when calling "lookahead(..)" and consumed when calling "match (..)". - Specified by:
getLocationin interfaceSAXEventStream
-
headToString
Description copied from interface:SAXEventStreamReturns the conventional textual representation of the current head. Raises Nullpointer Exception if no such exists.- Specified by:
headToStringin interfaceSAXEventStream
-
drainTo
- Throws:
SAXException
-