01: /*
02: JSPWiki - a JSP-based WikiWiki clone.
03:
04: Copyright (C) 2001-2002 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.tags;
21:
22: import com.ecyrd.jspwiki.WikiEngine;
23:
24: import java.io.IOException;
25:
26: /**
27: * Root class for different internal wiki links. Cannot be used directly,
28: * but provides basic stuff for other classes.
29: * <P>
30: * Extend from this class if you need the following attributes.
31: *
32: * <P><B>Attributes</B></P>
33: * <UL>
34: * <LI>page - Page name to refer to. Default is the current page.
35: * <li>format - Either "url" or "anchor". If "url", will provide
36: * just the URL for the link. If "anchor", will output proper HTML
37: * (<a> href="...).
38: * </UL>
39: *
40: * @author Janne Jalkanen
41: * @since 2.0
42: */
43: public abstract class WikiLinkTag extends WikiTagBase {
44: public static final int ANCHOR = 0;
45: public static final int URL = 1;
46:
47: protected String m_pageName;
48: protected int m_format = ANCHOR;
49: protected String m_template;
50:
51: public void setPage(String page) {
52: m_pageName = WikiEngine.makeAbsolutePageName(page);
53: }
54:
55: public String getPage() {
56: return m_pageName;
57: }
58:
59: public String getTemplate() {
60: return m_template;
61: }
62:
63: public void setTemplate(String arg) {
64: m_template = arg;
65: }
66:
67: public void setFormat(String mode) {
68: if ("url".equalsIgnoreCase(mode)) {
69: m_format = URL;
70: } else {
71: m_format = ANCHOR;
72: }
73: }
74:
75: public int doEndTag() {
76: try {
77: if (m_format == ANCHOR) {
78: pageContext.getOut().print("</a>");
79: }
80: } catch (IOException e) {
81: // FIXME: Should do something?
82: }
83:
84: return EVAL_PAGE;
85: }
86: }
|