public class LanguagePrefilter extends TextPrefilter
==Language==
, this filter also allows (1) spaces around the language
(e.g., (== Language ==
and (2) the language to be a link (e.g., "==[[Language]]=="
.
This filter also passes through the following language tag. For example, given this text:
==Polish== Polish content goes here ==Spanish==
The ==Spanish==
tag would get passed. (We do this because delaying the passing of
partial language tags until we know for sure whether or not they are tags would greatly complicate the code.
It is much easier to have the post-filter remove the trailing tag.)
Constructor and Description |
---|
LanguagePrefilter(Pattern pattern)
Constructor specifying a regular expression that the header must match.
|
LanguagePrefilter(String language)
Constructor specifying a specific header.
|
Modifier and Type | Method and Description |
---|---|
protected void |
handleEndTextElement(String uri,
String localName,
String name)
Called when an ending
</text> is reached. |
protected void |
handleStartTextElement(String uri,
String localName,
String name,
Attributes attrs)
Called at the beginning of an XML
<text> element. |
protected void |
handleTextElementCharacters(char[] ch,
int start,
int length)
Called after the underlying SAX parser reads a set of
<text>
data. |
characters, endElement, getCurrentTitle, sendCharacters, startElement
endDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
public LanguagePrefilter(String language)
language
- language to search forpublic LanguagePrefilter(Pattern pattern)
Pattern.compile("P[ei]g")
will match "==Peg==" and "==Pig==". Note, however:
pattern
- regular expression that the header must match.protected void handleStartTextElement(String uri, String localName, String name, Attributes attrs) throws SAXException
TextPrefilter
<text>
element. See XMLFilterImpl
.handleStartTextElement
in class TextPrefilter
uri
- The element's Namespace URI, or the empty string.localName
- The element's local name, or the empty string.name
- The element's qualified (prefixed) name, or the empty string.attrs
- The element's attributes.SAXException
- The client may throw an exception during processing.protected void handleEndTextElement(String uri, String localName, String name) throws SAXException
TextPrefilter
</text>
is reached.handleEndTextElement
in class TextPrefilter
uri
- The element's Namespace URI, or the empty string.localName
- The element's local name, or the empty string.name
- The element's qualified (prefixed) name, or the empty string.SAXException
- The client may throw an exception during processing.protected void handleTextElementCharacters(char[] ch, int start, int length) throws SAXException
TextPrefilter
<text>
data. See XMLFilterImpl
.handleTextElementCharacters
in class TextPrefilter
ch
- An array of characters.start
- The starting position in the array.length
- The number of characters to use from the array.SAXException
- The client may throw an exception during processing.