org.apache.ecs.filter
Class CharacterFilter

java.lang.Object
  extended by java.util.Dictionary
      extended by java.util.Hashtable
          extended by org.apache.ecs.filter.CharacterFilter
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map, Filter

public class CharacterFilter
extends java.util.Hashtable
implements Filter

This class creates a Filter object. The default characters filtered are:
" ' & < >

For example:


    Filter filter = new CharacterFilter();
    filter.addAttribute("$","dollar");
    filter.addAttribute("#",Entities.POUND);

    P p = new P();
    p.setFilter(filter);

    Document doc = new Document();
    doc.getBody().addElement(p);
    
The filter is applied when the addElement() method is called.

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

Constructor Summary
CharacterFilter()
           
 
Method Summary
 Filter addAttribute(java.lang.String name, java.lang.Object attribute)
          Register things to be filtered.
 java.lang.String getInfo()
          Returns the name of the filter
 boolean hasAttribute(java.lang.String key)
          Check to see if something is going to be filtered.
 java.lang.String process(java.lang.String to_process)
          Perform the filtering operation.
 Filter removeAttribute(java.lang.String name)
          Remove things to be filtered.
 
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
 

Constructor Detail

CharacterFilter

public CharacterFilter()
Method Detail

getInfo

public java.lang.String getInfo()
Returns the name of the filter

Specified by:
getInfo in interface Filter

addAttribute

public Filter addAttribute(java.lang.String name,
                           java.lang.Object attribute)
Register things to be filtered.

Specified by:
addAttribute in interface Filter

removeAttribute

public Filter removeAttribute(java.lang.String name)
Remove things to be filtered.

Specified by:
removeAttribute in interface Filter

hasAttribute

public boolean hasAttribute(java.lang.String key)
Check to see if something is going to be filtered.

Specified by:
hasAttribute in interface Filter

process

public java.lang.String process(java.lang.String to_process)
Perform the filtering operation.

Specified by:
process in interface Filter


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