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.fixtures;
04:
05: import fit.*;
06:
07: public class StringFixture extends ColumnFixture {
08: public int subStringSize = 10;
09:
10: public String value;
11:
12: private String expected;
13:
14: public void check(Parse cell, TypeAdapter a) {
15: expected = cell.text();
16: super .check(cell, a);
17: }
18:
19: public void execute() throws Exception {
20: value = value.trim();
21: }
22:
23: public String startsWith() {
24: if (value.startsWith(expected))
25: return expected;
26: else {
27: if (value.length() <= subStringSize)
28: return value;
29: else
30: return value.substring(0, subStringSize) + "...";
31: }
32: }
33:
34: public String endsWith() {
35: if (value.endsWith(expected))
36: return expected;
37: else {
38: if (value.length() <= subStringSize)
39: return value;
40: else
41: return "..."
42: + value.substring(value.length()
43: - subStringSize);
44: }
45: }
46:
47: public String contains() {
48: if (value.indexOf(expected) != -1)
49: return expected;
50: else {
51: if (value.length() <= subStringSize)
52: return value;
53: else
54: return "...";
55: }
56: }
57: }
|