org.mmbase.util.transformers
Class RegexpReplacer
java.lang.Object
org.mmbase.util.transformers.ReaderTransformer
org.mmbase.util.transformers.ConfigurableReaderTransformer
org.mmbase.util.transformers.ChunkedTransformer
org.mmbase.util.transformers.RegexpReplacer
- All Implemented Interfaces:
- CharTransformer, ConfigurableTransformer, Serializable, Transformer
- Direct Known Subclasses:
- Censor, LinkFinder
- public class RegexpReplacer
- extends ChunkedTransformer
Finds regexps in the Character String, and replaces them. The replaced regexps can be found in a configuration file 'regexps.xml' (if it is present).
It ignores existing XML markup, and also avoids trailing dots and comments and surrounding quotes and parentheses.
- Since:
- MMBase-1.8
- Author:
- Michiel Meeuwissen
- See Also:
- Serialized Form
|
Field Summary |
protected static Collection |
regexps
The regexps for the unextended RegexpReplacer |
| Methods inherited from class org.mmbase.util.transformers.ChunkedTransformer |
configure, getEncoding, newStatus, replace, replaceWord, transform, transformEntire, transformers, transformLines, transformWords, transformXmlText, transformXmlTextWords |
regexps
protected static final Collection regexps
- The regexps for the unextended RegexpReplacer
RegexpReplacer
public RegexpReplacer(int i)
RegexpReplacer
public RegexpReplacer()
getPatterns
protected Collection getPatterns()
- This on default gives the regexps configured for the base-class (a static member). You can
override this method to return another Collection.
getConfigFile
protected String getConfigFile()
- This can be overridden if the implementation must use its own configuration file.
readDefaultPatterns
protected void readDefaultPatterns(Collection patterns)
- Reads defaults translation patterns into the given collection patterns. Override this for
other default patterns.
readPatterns
protected final void readPatterns(Collection patterns)
- Reads patterns from config-file into given Collection
addPatterns
protected static void addPatterns(Collection list,
Collection patterns)
- Utility function to create a bunch of patterns.
- Parameters:
list - A Collection of Map.Entry (like Map.entrySet()), containing
pairs of Stringspatterns - This the Collection of Entries. The key of every entry is a compiled regular
expression. The value is still a String. New entries will be added to this collection
by this function.
replace
protected boolean replace(String string,
Writer w,
ChunkedTransformer.Status status)
throws IOException
- Description copied from class:
ChunkedTransformer
- Implement this. Return true if a replacement done.
- Specified by:
replace in class ChunkedTransformer
- Throws:
IOException
base
protected final String base()
- Specified by:
base in class ChunkedTransformer
toString
public String toString()
- Specified by:
toString in interface Transformer- Overrides:
toString in class ConfigurableReaderTransformer
MMBase build 1.8.1.20060716