org.ceryle.wiki.plugin.tag
Class TagManagerImpl

java.lang.Object
  extended by org.ceryle.wiki.plugin.tag.TagManagerImpl
All Implemented Interfaces:
TagManager

public class TagManagerImpl
extends Object
implements TagManager

Implements the TagManager API as a singleton-per-WikiEngine class, handling plugin-based set and get tag methods and listening for WikiPageEvents for the management and querying of user tags.

If the system property PROPERTY_USECACHE is false, will not use query caching (otherwise yes).

See Also:
TagManager, TagManagerFactory

Nested Class Summary
 class TagManagerImpl.HasTagModifier
          A substitution for the IS Operator as a component of a query expression.
 
Field Summary
static int crawlDelay
          The delay in milliseconds following instantiation prior to starting the wiki crawler.
static String PROPERTY_USECACHE
          The System property name for the property enabling the TagManager's cache.
static boolean requirePageForTag
          When true, require all tags to be represented by wiki pages matching the tag name.
 
Fields inherited from interface org.ceryle.wiki.plugin.tag.TagManager
LOGICAL_AND, LOGICAL_NOT, LOGICAL_OR, TAG_PROPERTY
 
Constructor Summary
protected TagManagerImpl(WikiEngine engine)
          Create an TagManagerImpl for the provided WikiEngine.
 
Method Summary
 void convertToTerms(List terms, String pagename)
          Provided with a List of Strings and Terms, converts any square-bracketed Strings in the List to Terms.
 Set getAllTags()
          Returns the alphabetically-sorted Set of all tags, an empty List if no tags exist.
 WikiEngine getEngine()
          Returns the WikiEngine associated with this AssertionHandler.
 List getPagesForTag(String tag)
          Returns the List of wiki page names (as Strings) containing the provided tag, an empty List if no matches exist.
 QueryItem getQueryForExpression(Expression expression)
          Return a QueryItem corresponding to the provided Expression.
 List getTagsForPage(String pagename)
          Returns the List of tags (as Strings) for the provided Page, an empty List if none have been set.
 boolean hasTag(String pagename, String tag)
          Returns true if the wiki page contains the tag, false if it does not contain the tag or the page does not exist.
 boolean isListenerEnabled()
          Returns the enabled state of this AssertionHandler's WikiEventListener.
 Set processQuery(WikiContext context, Map params)
          Processes the parameters as a query, returning the resulting Set of wiki page names.
 void setListenerEnabled(boolean enable)
          Enables or disables this TagManager's WikiEventListener so that it tracks or no longer tracks changes to the wiki.
 void setTagsForPage(String pagename, List terms)
          Sets the List of tags (as Strings) for the provided Page, replacing any previous List.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requirePageForTag

public static boolean requirePageForTag
When true, require all tags to be represented by wiki pages matching the tag name. Default is true.


crawlDelay

public static int crawlDelay
The delay in milliseconds following instantiation prior to starting the wiki crawler. The default is 7000 (7 seconds).


PROPERTY_USECACHE

public static final String PROPERTY_USECACHE
The System property name for the property enabling the TagManager's cache. The property value should be 'true' or 'false'. The name of the property is "ceryle.tagmanager.usecache".

See Also:
Constant Field Values
Constructor Detail

TagManagerImpl

protected TagManagerImpl(WikiEngine engine)
Create an TagManagerImpl for the provided WikiEngine.

Parameters:
engine - the WikiEngine this TagManager serves.
Method Detail

processQuery

public Set processQuery(WikiContext context,
                        Map params)
                 throws QueryException
Processes the parameters as a query, returning the resulting Set of wiki page names.

Specified by:
processQuery in interface TagManager
Throws:
QueryException

getQueryForExpression

public QueryItem getQueryForExpression(Expression expression)
Return a QueryItem corresponding to the provided Expression. If caching is turned on this may come from the cache.

Specified by:
getQueryForExpression in interface TagManager

convertToTerms

public void convertToTerms(List terms,
                           String pagename)
                    throws PluginException
Provided with a List of Strings and Terms, converts any square-bracketed Strings in the List to Terms. If the pagename parameter is non-null, any instances of "[.]" will be replaced by "[pagename]".

Specified by:
convertToTerms in interface TagManager
Parameters:
terms - the List of Terms
pagename - the wiki page name of the plugin's origin
Throws:
PluginException

getAllTags

public Set getAllTags()
Returns the alphabetically-sorted Set of all tags, an empty List if no tags exist.


hasTag

public boolean hasTag(String pagename,
                      String tag)
Returns true if the wiki page contains the tag, false if it does not contain the tag or the page does not exist. Throws a NullPointerException if either argument is null.

Specified by:
hasTag in interface TagManager

getPagesForTag

public List getPagesForTag(String tag)
Returns the List of wiki page names (as Strings) containing the provided tag, an empty List if no matches exist.

Specified by:
getPagesForTag in interface TagManager

getTagsForPage

public List getTagsForPage(String pagename)
Returns the List of tags (as Strings) for the provided Page, an empty List if none have been set.

Specified by:
getTagsForPage in interface TagManager

setTagsForPage

public void setTagsForPage(String pagename,
                           List terms)
Sets the List of tags (as Strings) for the provided Page, replacing any previous List. A null value for the List will remove any record for that page from the registry.

Specified by:
setTagsForPage in interface TagManager

getEngine

public WikiEngine getEngine()
Returns the WikiEngine associated with this AssertionHandler.

This is an AssertionHandler API method.

Specified by:
getEngine in interface TagManager

setListenerEnabled

public void setListenerEnabled(boolean enable)
Enables or disables this TagManager's WikiEventListener so that it tracks or no longer tracks changes to the wiki.

The listener is created upon class instantiation, and removed from the WikiEventManager and destroyed when this method is called with a parameter value of false.

Specified by:
setListenerEnabled in interface TagManager

isListenerEnabled

public boolean isListenerEnabled()
Returns the enabled state of this AssertionHandler's WikiEventListener. If the listener is disabled, the internal registry should be considered invalid.

This is an AssertionHandler API method.

Specified by:
isListenerEnabled in interface TagManager


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.