org.apache.ecs.filter
Class RegexpFilter
java.lang.Object
java.util.Dictionary
java.util.Hashtable
org.apache.ecs.filter.RegexpFilter
- All Implemented Interfaces:
- java.lang.Cloneable, Filter, java.util.Map, java.io.Serializable
- public class RegexpFilter
- extends java.util.Hashtable
- implements Filter
This filter uses regexp to create expressions and allows
you do a replace on them.
It works like the Perl function called subst. Given a regular
expression of "a*b", and a String to substituteIn of
"aaaabfooaaabgarplyaaabwackyb" and the substitution String "-", the
resulting String returned by subst would be "-foo-garply-wacky-".
Filter filter = new RegexpFilter();
filter.addAttribute("a*b","-");
String text = "aaaabfooaaabgarplyaaabwackyb";
String result = filter.process(text);
System.out.println(result);
Produces: -foo-garply-wacky-
Note: "a*" means 0 or more occurences of 'a', therefore the last match
is absolutely correct.
For more information about the regular expression package please do
visit Jakarta Regexp"
- Version:
- $Id: RegexpFilter.java,v 1.2 2003/04/27 09:28:56 rdonkin Exp $
- Author:
- K. Zelazowski
- See Also:
- Serialized Form
Nested classes inherited from class java.util.Hashtable |
|
Fields inherited from class java.util.Hashtable |
|
Method Summary |
Filter |
addAttribute(java.lang.String expression,
java.lang.Object substitution)
Add regular expression - substitution pair. |
java.lang.String |
getInfo()
Returns the name of the filter |
boolean |
hasAttribute(java.lang.String expression)
Returns true if this filter contains an expression specified
as an argument. |
java.lang.String |
process(java.lang.String to_process)
This method actually performs the filtering. |
Filter |
removeAttribute(java.lang.String expression)
Get rid of the specified expression filter. |
Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
RegexpFilter
public RegexpFilter()
getInfo
public java.lang.String getInfo()
- Returns the name of the filter
- Specified by:
getInfo
in interface Filter
process
public java.lang.String process(java.lang.String to_process)
- This method actually performs the filtering.
- Specified by:
process
in interface Filter
addAttribute
public Filter addAttribute(java.lang.String expression,
java.lang.Object substitution)
- Add regular expression - substitution pair.
- Specified by:
addAttribute
in interface Filter
- Returns:
- itself or null if the was an error in the syntax of the
expression.
removeAttribute
public Filter removeAttribute(java.lang.String expression)
- Get rid of the specified expression filter.
- Specified by:
removeAttribute
in interface Filter
hasAttribute
public boolean hasAttribute(java.lang.String expression)
- Returns true if this filter contains an expression specified
as an argument.
- Specified by:
hasAttribute
in interface Filter
Copyright © 1999-2003 Apache Software Foundation. All Rights Reserved.