org.apache.ecs.filter
Class WordFilter

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--org.apache.ecs.filter.WordFilter
All Implemented Interfaces:
java.lang.Cloneable, Filter, java.util.Map, java.io.Serializable

public class WordFilter
extends java.util.Hashtable
implements Filter

This filter uses StringTokenizer to create "words" and allow you to replace on those "words". A word is defined as anything between two spaces. This filter should be relatively fast and shows how easy it is to implement your own filters.


Filter filter = new WordFilter();
filter.addAttribute("there","where");
filter.addAttribute("it","is");
filter.addAttribute("goes","it");
P p = new P();
p.setFilter(filter);
p.addElement("there it goes");
System.out.println(p.toString());
Produces: <p>where is it

Version:
$Id: WordFilter.java,v 1.5 2003/04/27 09:28:56 rdonkin Exp $
Author:
Stephan Nagy, Jon S. Stevens
See Also:
Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Fields inherited from class java.util.Hashtable
count, emptyEnumerator, emptyIterator, ENTRIES, entrySet, KEYS, keySet, loadFactor, modCount, serialVersionUID, table, threshold, values, VALUES
 
Constructor Summary
WordFilter()
           
 
Method Summary
 Filter addAttribute(java.lang.String attribute, java.lang.Object entity)
          Put a filter somewhere we can get to it.
 java.lang.String getInfo()
          Returns the name of the filter
 boolean hasAttribute(java.lang.String attribute)
          Does the filter filter this?
 java.lang.String process(java.lang.String to_process)
          this method actually performs the filtering.
 Filter removeAttribute(java.lang.String attribute)
          Get rid of a current filter.
 
Methods inherited from class java.util.Hashtable
, clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, getEnumeration, getIterator, hashCode, isEmpty, keys, keySet, put, putAll, readObject, rehash, remove, size, toString, values, writeObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Constructor Detail

WordFilter

public WordFilter()
Method Detail

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 attribute,
                           java.lang.Object entity)
Put a filter somewhere we can get to it.
Specified by:
addAttribute in interface Filter

removeAttribute

public Filter removeAttribute(java.lang.String attribute)
Get rid of a current filter.
Specified by:
removeAttribute in interface Filter

hasAttribute

public boolean hasAttribute(java.lang.String attribute)
Does the filter filter this?
Specified by:
hasAttribute in interface Filter


Copyright © 1999-2003 Apache Software Foundation. All Rights Reserved.