org.apache.wiki.api.filters
Class BasicPageFilter

java.lang.Object
  extended by org.apache.wiki.api.filters.BasicPageFilter
All Implemented Interfaces:
PageFilter
Direct Known Subclasses:
CreoleFilter, PageEventFilter, PingWeblogsComFilter, ProfanityFilter, ReferenceManager, SearchManager, SpamFilter

public class BasicPageFilter
extends Object
implements PageFilter

Provides a base implementation of a PageFilter. None of the callbacks do anything, so it is a good idea for you to extend from this class and implement only methods that you need.


Field Summary
protected  WikiEngine m_engine
           
 
Constructor Summary
BasicPageFilter()
           
 
Method Summary
 void destroy(WikiEngine engine)
          Called for every filter, e.g. on wiki engine shutdown.
 void initialize(WikiEngine engine, Properties properties)
          If you override this, you should call super.initialize() first.
 void postSave(WikiContext wikiContext, String content)
          This method is called after the page has been successfully saved.
 String postTranslate(WikiContext wikiContext, String htmlContent)
          This method is called after a page has been fed through the translation process, so anything you are seeing here is translated content.
 String preSave(WikiContext wikiContext, String content)
          This method is called before the page has been saved to the PageProvider.
 String preTranslate(WikiContext wikiContext, String content)
          This method is called whenever a page has been loaded from the provider, but not yet been sent through the markup-translation process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_engine

protected WikiEngine m_engine
Constructor Detail

BasicPageFilter

public BasicPageFilter()
Method Detail

initialize

public void initialize(WikiEngine engine,
                       Properties properties)
                throws FilterException
If you override this, you should call super.initialize() first. Is called whenever the a new PageFilter is instantiated and reset.

Specified by:
initialize in interface PageFilter
Parameters:
engine - The WikiEngine whic owns this PageFilter
properties - The properties ripped from filters.xml.
Throws:
FilterException - If the filter could not be initialized. If this is thrown, the filter is not added to the internal queues.

preTranslate

public String preTranslate(WikiContext wikiContext,
                           String content)
                    throws FilterException
This method is called whenever a page has been loaded from the provider, but not yet been sent through the markup-translation process. Note that you cannot do HTML translation here, because it will be escaped.

Specified by:
preTranslate in interface PageFilter
Parameters:
wikiContext - The current wikicontext.
content - WikiMarkup.
Returns:
The modified wikimarkup content.
Throws:
FilterException - If something goes wrong. Throwing this causes the entire page processing to be abandoned.

postTranslate

public String postTranslate(WikiContext wikiContext,
                            String htmlContent)
                     throws FilterException
This method is called after a page has been fed through the translation process, so anything you are seeing here is translated content. If you want to do any of your own WikiMarkup2HTML translation, do it here.

Specified by:
postTranslate in interface PageFilter
Parameters:
wikiContext - The WikiContext.
htmlContent - The translated HTML
Returns:
The modified HTML
Throws:
FilterException - If something goes wrong. Throwing this causes the entire page processing to be abandoned.

preSave

public String preSave(WikiContext wikiContext,
                      String content)
               throws FilterException
This method is called before the page has been saved to the PageProvider.

Specified by:
preSave in interface PageFilter
Parameters:
wikiContext - The WikiContext
content - The wikimarkup that the user just wanted to save.
Returns:
The modified wikimarkup
Throws:
FilterException - If something goes wrong. Throwing this causes the entire page processing to be abandoned.

postSave

public void postSave(WikiContext wikiContext,
                     String content)
              throws FilterException
This method is called after the page has been successfully saved. If the saving fails for any reason, then this method will not be called.

Since the result is discarded from this method, this is only useful for things like counters, etc.

Specified by:
postSave in interface PageFilter
Parameters:
wikiContext - The WikiContext
content - The content which was just stored.
Throws:
FilterException - If something goes wrong. As the page is already saved, This is just logged.

destroy

public void destroy(WikiEngine engine)
Called for every filter, e.g. on wiki engine shutdown. Use this if you have to clean up or close global resources you allocated in the initialize() method.

Specified by:
destroy in interface PageFilter
Parameters:
engine - The WikiEngine which owns this filter.


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.