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 fitnesse.wikitext.WikiWidget;
06:
07: import java.util.regex.Pattern;
08: import java.util.regex.Matcher;
09:
10: public class LiteralWidget extends WikiWidget {
11: public static final String REGEXP = "!lit\\(\\d+\\)";
12:
13: public static final Pattern pattern = Pattern.compile(
14: "!lit\\((\\d+)\\)", Pattern.MULTILINE + Pattern.DOTALL);
15:
16: private int literalNumber;
17:
18: public LiteralWidget(ParentWidget parent, String text) {
19: super (parent);
20: Matcher match = pattern.matcher(text);
21: if (match.find()) {
22: literalNumber = Integer.parseInt(match.group(1));
23: }
24: }
25:
26: public String render() throws Exception {
27: return parent.getLiteral(literalNumber);
28: }
29:
30: public String asWikiText() throws Exception {
31: return "!-" + parent.getLiteral(literalNumber) + "-!";
32: }
33: }
|