01: /*
02: JSPWiki - a JSP-based WikiWiki clone.
03:
04: Copyright (C) 2001-2006 Janne Jalkanen (Janne.Jalkanen@iki.fi)
05:
06: This program is free software; you can redistribute it and/or modify
07: it under the terms of the GNU Lesser General Public License as published by
08: the Free Software Foundation; either version 2.1 of the License, or
09: (at your option) any later version.
10:
11: This program is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU Lesser General Public License for more details.
15:
16: You should have received a copy of the GNU Lesser General Public License
17: along with this program; if not, write to the Free Software
18: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: package com.ecyrd.jspwiki.render;
21:
22: import java.io.IOException;
23:
24: import com.ecyrd.jspwiki.TextUtil;
25: import com.ecyrd.jspwiki.WikiContext;
26: import com.ecyrd.jspwiki.WikiEngine;
27: import com.ecyrd.jspwiki.parser.MarkupParser;
28: import com.ecyrd.jspwiki.parser.WikiDocument;
29:
30: /**
31: * Provides an interface to the basic rendering engine.
32: * This class is an abstract class instead of an interface because
33: * it is expected that rendering capabilities are increased at some
34: * point, and I would hate if renderers broke. This class allows
35: * some sane defaults to be implemented.
36: *
37: * @author jalkanen
38: * @since 2.4
39: */
40: public abstract class WikiRenderer {
41: protected WikiContext m_context;
42: protected WikiDocument m_document;
43: protected boolean m_enablePlugins = true;
44:
45: protected WikiRenderer(WikiContext context, WikiDocument doc) {
46: m_context = context;
47: m_document = doc;
48: doc.setContext(context); // Make sure it is set
49:
50: //
51: // Do some sane defaults
52: //
53: WikiEngine engine = m_context.getEngine();
54: String runplugins = engine.getVariable(m_context,
55: MarkupParser.PROP_RUNPLUGINS);
56: if (runplugins != null)
57: enablePlugins(TextUtil.isPositive(runplugins));
58: }
59:
60: /**
61: * Can be used to turn on plugin execution on a translator-reader basis
62: */
63: public void enablePlugins(boolean toggle) {
64: m_enablePlugins = toggle;
65: }
66:
67: public abstract String getString() throws IOException;
68:
69: }
|