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: import fitnesse.wikitext.WidgetBuilder;
09:
10: public class ClasspathWidget extends ParentWidget implements
11: WidgetWithTextArgument {
12: public static final String REGEXP = "^!path [^\r\n]*";
13: private static final Pattern pattern = Pattern
14: .compile("^!path (.*)");
15: private String pathText;
16:
17: public ClasspathWidget(ParentWidget parent, String text)
18: throws Exception {
19: super (parent);
20: Matcher match = pattern.matcher(text);
21: if (match.find()) {
22: pathText = match.group(1);
23: addChildWidgets(pathText);
24: }
25: }
26:
27: public WidgetBuilder getBuilder() {
28: return WidgetBuilder.variableWidgetBuilder;
29: }
30:
31: public String render() throws Exception {
32: return HtmlUtil.metaText("classpath: " + childHtml());
33: }
34:
35: public String asWikiText() throws Exception {
36: return "!path " + pathText;
37: }
38:
39: public String getText() throws Exception {
40: return childHtml();
41: }
42: }
|