public class PageEventFilter extends BasicPageFilter
Adding a PageEventFilter to the FilterManager will automatically attach an event delegate with the WikiEventManager to provide for firing and listener management. All that remains is then adding the listener to the filter via the WikiEventManager. This is quite simple:
PageEventFilter filter = new PageEventFilter(); engine.getFilterManager().addPageFilter(filter,5000); // attach listener to filter WikiEventManager.addWikiEventListener(filter,listener);
This class provides convenience methods for adding and removing WikiEventListeners.
WikiEventManager
m_engine
Constructor and Description |
---|
PageEventFilter() |
Modifier and Type | Method and Description |
---|---|
void |
addWikiEventListener(WikiEventListener listener)
Registers a WikiEventListener with this instance.
|
protected void |
fireEvent(int type,
WikiContext context)
Fires a WikiPageEvent of the provided type and page name
to all registered listeners.
|
void |
initialize(Properties properties)
Called whenever a new PageFilter is instantiated and reset.
|
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 TranslatorReader,
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 TranslatorReader.
|
void |
removeWikiEventListener(WikiEventListener listener)
Un-registers a WikiEventListener with this instance.
|
destroy, initialize
public PageEventFilter()
public void initialize(Properties properties) throws FilterException
FilterException
public String preTranslate(WikiContext wikiContext, String content) throws FilterException
preTranslate
in interface PageFilter
preTranslate
in class BasicPageFilter
wikiContext
- The current wikicontext.content
- WikiMarkup.FilterException
- If something goes wrong. Throwing this causes the entire page
processing to be abandoned.public String postTranslate(WikiContext wikiContext, String htmlContent) throws FilterException
postTranslate
in interface PageFilter
postTranslate
in class BasicPageFilter
wikiContext
- The WikiContext.htmlContent
- The translated HTMLFilterException
- If something goes wrong. Throwing this causes the entire page
processing to be abandoned.public String preSave(WikiContext wikiContext, String content) throws FilterException
preSave
in interface PageFilter
preSave
in class BasicPageFilter
wikiContext
- The WikiContextcontent
- The wikimarkup that the user just wanted to save.FilterException
- If something goes wrong. Throwing this causes the entire page
processing to be abandoned.public void postSave(WikiContext wikiContext, String content) throws FilterException
Since the result is discarded from this method, this is only useful for things like counters, etc.
postSave
in interface PageFilter
postSave
in class BasicPageFilter
wikiContext
- The WikiContextcontent
- The content which was just stored.FilterException
- If something goes wrong. As the page is already saved,
This is just logged.public final void addWikiEventListener(WikiEventListener listener)
listener
- the event listenerpublic final void removeWikiEventListener(WikiEventListener listener)
listener
- the event listenerprotected final void fireEvent(int type, WikiContext context)
type
- the WikiPageEvent type to be fired.context
- the WikiContext of the event.WikiPageEvent
Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.