com.ecyrd.jspwiki.filters
Class FilterManager

java.lang.Object
  extended by com.ecyrd.jspwiki.filters.FilterManager

public class FilterManager
extends Object

Manages the page filters. Page filters are components that can be executed at certain places:

Using page filters allows you to modify the page data on-the-fly, and do things like adding your own custom WikiMarkup.

The initial page filter configuration is kept in a file called "filters.xml". The format is really very simple:

  
 
  

    
      com.ecyrd.jspwiki.filters.ProfanityFilter
    
  
    
      com.ecyrd.jspwiki.filters.TestFilter

      
        foobar
        Zippadippadai
      

      
        blatblaa
        5
      

    
  
  
The <filter> -sections define the filters. For more information, please see the PageFilterConfiguration page in the JSPWiki distribution.

Author:
Janne Jalkanen

Field Summary
static String DEFAULT_XMLFILE
           
static String PROP_FILTERXML
           
static int SYSTEM_FILTER_PRIORITY
          JSPWiki system filters are all below this value.
static int USER_FILTER_PRIORITY
          The standard user level filtering.
 
Constructor Summary
FilterManager(WikiEngine engine, Properties props)
           
 
Method Summary
 void addPageFilter(PageFilter f, int priority)
          Adds a page filter to the queue.
 void doPostSaveFiltering(WikiContext context, String pageData)
          Does the page filtering after the page has been saved.
 String doPostTranslateFiltering(WikiContext context, String pageData)
          Does the filtering after HTML translation.
 String doPreSaveFiltering(WikiContext context, String pageData)
          Does the filtering before a save to the page repository.
 String doPreTranslateFiltering(WikiContext context, String pageData)
          Does the filtering before a translation.
 List getFilterList()
           
 void initialize(WikiEngine engine, Properties props)
          Initializes the filters from an XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_FILTERXML

public static final String PROP_FILTERXML
See Also:
Constant Field Values

DEFAULT_XMLFILE

public static final String DEFAULT_XMLFILE
See Also:
Constant Field Values

SYSTEM_FILTER_PRIORITY

public static final int SYSTEM_FILTER_PRIORITY
JSPWiki system filters are all below this value.

See Also:
Constant Field Values

USER_FILTER_PRIORITY

public static final int USER_FILTER_PRIORITY
The standard user level filtering.

See Also:
Constant Field Values
Constructor Detail

FilterManager

public FilterManager(WikiEngine engine,
                     Properties props)
              throws WikiException
Throws:
WikiException
Method Detail

addPageFilter

public void addPageFilter(PageFilter f,
                          int priority)
Adds a page filter to the queue. The priority defines in which order the page filters are run, the highest priority filters go in the queue first.

In case two filters have the same priority, their execution order is the insertion order.

Parameters:
f - PageFilter to add
priority - The priority in which position to add it in.
Throws:
IllegalArgumentException - If the PageFilter is null or invalid.
Since:
2.1.44.

initialize

public void initialize(WikiEngine engine,
                       Properties props)
                throws WikiException
Initializes the filters from an XML file.

Throws:
WikiException

doPreTranslateFiltering

public String doPreTranslateFiltering(WikiContext context,
                                      String pageData)
                               throws FilterException
Does the filtering before a translation.

Throws:
FilterException

doPostTranslateFiltering

public String doPostTranslateFiltering(WikiContext context,
                                       String pageData)
                                throws FilterException
Does the filtering after HTML translation.

Throws:
FilterException

doPreSaveFiltering

public String doPreSaveFiltering(WikiContext context,
                                 String pageData)
                          throws FilterException
Does the filtering before a save to the page repository.

Throws:
FilterException

doPostSaveFiltering

public void doPostSaveFiltering(WikiContext context,
                                String pageData)
                         throws FilterException
Does the page filtering after the page has been saved.

Throws:
FilterException

getFilterList

public List getFilterList()