01: package com.ecyrd.jspwiki.plugin;
02:
03: import java.util.Map;
04:
05: import com.ecyrd.jspwiki.WikiContext;
06: import com.ecyrd.jspwiki.parser.PluginContent;
07:
08: /**
09: * Implements a simple plugin that just returns its text.
10: * <P>
11: * Parameters: text - text to return.
12: * Any _body content gets appended between brackets.
13: *
14: * @author Janne Jalkanen
15: */
16: public class SamplePlugin implements WikiPlugin, ParserStagePlugin {
17: protected static boolean c_rendered = false;
18:
19: public String execute(WikiContext context, Map params)
20: throws PluginException {
21: StringBuffer sb = new StringBuffer();
22:
23: String text = (String) params.get("text");
24:
25: if (text != null) {
26: sb.append(text);
27: }
28:
29: String body = (String) params.get("_body");
30: if (body != null) {
31: sb.append(" (" + body.replace('\n', '+') + ")");
32: }
33:
34: return sb.toString();
35: }
36:
37: public void executeParser(PluginContent element,
38: WikiContext context, Map params) {
39: if (element.getParameter("render") != null)
40: c_rendered = true;
41: }
42:
43: }
|