public abstract class WordBufferingFilter extends AncestorXMLFilter
This abstract filter should be extended by outfilters that process blocks of word/space/punctuation elements.
This SAX filter buffers adjacent word/punctuation/space elements to allow easier processing in word-by-word based filters. The default behaviour is to buffer all word/space/punctuation elements, however the filter can be constructed to buffer only word/space/punctuation elements inside a modified paragraph-level element.
The buffer is flushed in the following situations:
When the buffer is flushed, the WordBufferingFilter.flush() method is invoked. You should override WordBufferingFilter.processBuffer() to modify the
buffer's contents prior to outputting and override WordBufferingFilter.outputBuffer() to output the buffer in a different format.
| Constructor and Description |
|---|
WordBufferingFilter()
Constructs a new WordBufferingFilter which will buffer all word/space/punctuation elements.
|
WordBufferingFilter(boolean bufferModifiedOnly)
Constructs a new WordBufferingFilter specifying whether to construct a filter that will buffer all word/space/punctuation
elements or one that filters just those that appear inside a modified paragraph-level element.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int start,
int length)
Overrides the default
characters method. |
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
Overrides the default
endElement method. |
boolean |
isBufferModifiedOnly()
Returns whether the filter is only buffering inside modified paragraph-level elements.
|
void |
setwrapUnchangedText(java.lang.String value)
Sets whether unchanged text should be wrapped in a
deltaxml:textGroup. |
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
Overrides the default
startElement method. |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri) |
endDocument, getClosestAttributeValueFromAncestor, getClosestAttributeValueFromAnyAncestor, getGrandParentLocalName, getParentLocalName, getParentQName, getProperty, hasAncestor, hasAncestor, hasAncestorWithAttr, hasAncestorWithAttrValue, hasAncestorWithAttrValues, outputCharacters, outputEndElement, outputStartElement, popAncestorStack, pushAncestorStack, setProperty, stackDepth, startDocumentattributeDecl, comment, elementDecl, endCDATA, endDTD, endEntity, externalEntityDecl, internalEntityDecl, parse, parse, startCDATA, startDTD, startEntityendPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, skippedEntity, unparsedEntityDecl, warningpublic WordBufferingFilter()
public WordBufferingFilter(boolean bufferModifiedOnly)
bufferModifiedOnly - whether to only buffer word/punctuation/space elements inside modified paragraph-level elements.public void setwrapUnchangedText(java.lang.String value)
Sets whether unchanged text should be wrapped in a deltaxml:textGroup.
By default, unchanged text is not wrapped in a deltaxml:textGroup but if a value of true is passed
to this method, unchanged text will be wrapped.
value - whether or not to wrap unchanged text in a deltaxml:textGrouppublic boolean isBufferModifiedOnly()
public void startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
throws org.xml.sax.SAXException
startPrefixMapping in interface org.xml.sax.ContentHandlerstartPrefixMapping in class org.xml.sax.helpers.XMLFilterImplorg.xml.sax.SAXExceptionpublic void startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
throws org.xml.sax.SAXException
startElement method.startElement in interface org.xml.sax.ContentHandlerstartElement in class AncestorXMLFilteruri - the URI of the element's namespacelocalName - the element's localnameqName - the element's qualified nameatts - the element's attributesorg.xml.sax.SAXException - the superclass may throw an exception during processing.XMLFilterImpl.startElement(String, String, String, Attributes)public void endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
throws org.xml.sax.SAXException
endElement method.endElement in interface org.xml.sax.ContentHandlerendElement in class AncestorXMLFilteruri - the URI of the element's namespacelocalName - the element's localnameqName - the element's qualified nameorg.xml.sax.SAXException - the superclass may throw an exception during processing.XMLFilterImpl.endElement(String, String, String)public void characters(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
characters method.characters in interface org.xml.sax.ContentHandlercharacters in class org.xml.sax.helpers.XMLFilterImplch - an array of charactersstart - the starting position in the arraylength - the number of characters to use from the arrayorg.xml.sax.SAXException - the superclass may throw an exception during processing.XMLFilterImpl.characters(char[], int, int)