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