org.mmbase.util.transformers
Class RegexpReplacer
java.lang.Object
org.mmbase.util.transformers.ReaderTransformer
org.mmbase.util.transformers.ConfigurableReaderTransformer
org.mmbase.util.transformers.ChunkedTransformer<Pattern>
org.mmbase.util.transformers.RegexpReplacer
- All Implemented Interfaces:
- Serializable, CharTransformer, ConfigurableTransformer, Transformer
- Direct Known Subclasses:
- Censor, LinkFinder
public class RegexpReplacer
- extends ChunkedTransformer<Pattern>
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
- Version:
- $Id: RegexpReplacer.java 41057 2010-02-16 00:12:33Z michiel $
- Author:
- Michiel Meeuwissen
- See Also:
- Serialized Form
| 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<Entry<Pattern,String>> regexps
- The regexps for the unextended RegexpReplacer
replaceInA
protected boolean replaceInA
RegexpReplacer
public RegexpReplacer(int i)
RegexpReplacer
public RegexpReplacer()
getPatterns
protected Collection<Entry<Pattern,String>> 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<Entry<Pattern,String>> patterns)
- Reads defaults translation patterns into the given collection patterns. Override this for
other default patterns.
readPatterns
protected final void readPatterns(Collection<Entry<Pattern,String>> patterns)
- Reads patterns from config-file into given Collection
addPatterns
protected static void addPatterns(Collection<Map.Entry<String,String>> list,
Collection<Entry<Pattern,String>> 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<Pattern>
- Throws:
IOException
base
protected final String base()
- Specified by:
base in class ChunkedTransformer<Pattern>
toString
public String toString()
- Specified by:
toString in interface Transformer- Overrides:
toString in class ConfigurableReaderTransformer
main
public static void main(String[] arg)
MMBase 2.0-SNAPSHOT - null