/** {@inheritDoc} */ public String execute(WikiContext context, Map params) throws PluginException { // // First, determine which kind of name we use to store in // the WikiContext. // String countername = (String) params.get(PARAM_NAME); if (countername == null) { countername = DEFAULT_NAME; } else { countername = DEFAULT_NAME + "-" + countername; } // // Fetch the old value // Integer val = (Integer) context.getVariable(countername); if (val == null) { val = 0; } // // Check if we need to reset this // String start = (String) params.get(PARAM_START); if (start != null) { val = Integer.parseInt(start); } else { // // Determine how much to increment // Object incrementObj = params.get(PARAM_INCREMENT); int increment = DEFAULT_INCREMENT; if (incrementObj != null) { increment = (new Integer((String) incrementObj)).intValue(); } val = val + increment; } context.setVariable(countername, val); // // check if we want to hide the result (just count, don't show result on the page // Object showObj = params.get(PARAM_SHOW_RESULT); boolean show = DEFAULT_SHOW_RESULT; if (showObj != null) { show = TextUtil.isPositive((String) showObj); } if (show) { return val.toString(); } return ""; }