01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.wikitext.widgets;
04:
05: import java.util.regex.Pattern;
06: import java.util.regex.Matcher;
07: import fitnesse.html.HtmlUtil;
08:
09: public class XRefWidget extends ParentWidget implements
10: WidgetWithTextArgument {
11: public static final String REGEXP = "^!see "
12: + WikiWordWidget.REGEXP;
13: private static final Pattern pattern = Pattern
14: .compile("^!see (.*)");
15: private String pageName;
16:
17: public XRefWidget(ParentWidget parent, String text)
18: throws Exception {
19: super (parent);
20: Matcher match = pattern.matcher(text);
21: if (match.find()) {
22: pageName = match.group(1);
23: addChildWidgets(pageName);
24: }
25: }
26:
27: public String render() throws Exception {
28: return HtmlUtil.metaText("<b>See: " + childHtml() + "</b>");
29: }
30:
31: public String asWikiText() throws Exception {
32: return "!see " + pageName;
33: }
34:
35: public String getText() {
36: return pageName;
37: }
38: }
|