Class Counter

  • All Implemented Interfaces:
    Plugin

    public class Counter
    extends java.lang.Object
    implements Plugin
    Provides a page-specific counter, it is reset every time a page is rendered, so it is not usable as a hitcounter.
    Stores a variable in the WikiContext called "counter", with the name of the optionally specified variable "name".
    For example: If name is "thispage", then the variable name is called "counter-thispage".

    Parameters :

    • name - Name of the counter. Optional.
    • increment - The amount to increment, may be a negative value, default is 1. Optional.
    • showResult - Should the counter value be visible on the page, default is true. Optional.
    Since:
    1.9.30
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_NAME  
      static java.lang.String PARAM_INCREMENT
      Parameter name for setting the increment.
      static java.lang.String PARAM_NAME
      Parameter name for setting the name.
      static java.lang.String PARAM_SHOW_RESULT
      Parameter name for setting the showResult.
      static java.lang.String PARAM_START
      Parameter name for setting the start.
    • Constructor Summary

      Constructors 
      Constructor Description
      Counter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String execute​(Context context, java.util.Map<java.lang.String,​java.lang.String> params)
      This is the main entry point for any plugin.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • execute

        public java.lang.String execute​(Context context,
                                        java.util.Map<java.lang.String,​java.lang.String> params)
                                 throws PluginException
        This is the main entry point for any plugin. The parameters are parsed, and a special parameter called "_body" signifies the name of the plugin body, i.e. the part of the plugin that is not a parameter of the form "key=value". This has been separated using an empty line.

        Note that it is preferred that the plugin returns XHTML-compliant HTML (i.e. close all tags, use <br /> instead of <br>, etc.

        Specified by:
        execute in interface Plugin
        Parameters:
        context - The current WikiContext.
        params - A Map which contains key-value pairs. Any parameter that the user has specified on the wiki page will contain String-String parameters, but it is possible that at some future date, JSPWiki will give you other things that are not Strings.
        Returns:
        HTML, ready to be included into the rendered page.
        Throws:
        PluginException - In case anything goes wrong.