01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.recorder;
14:
15: import java.util.regex.Matcher;
16: import java.util.regex.Pattern;
17:
18: /**
19: * Completely useless at the moment! This should become a handy tool for
20: * examination of result pages.
21: */
22: public class Response {
23: private String body;
24:
25: public Response(String body) {
26: this .body = body;
27: }
28:
29: public String getBody() {
30: return body;
31: }
32:
33: public String getTextValue(String name) {
34: Pattern p = Pattern.compile("name ?= ?\"" + name
35: + "\" .* value ?= ?\"([^\"]*)\"");
36: Matcher m = p.matcher(body);
37: m.find();
38: return m.group(1);
39: }
40:
41: public boolean isCheckBoxSelected(String name) {
42: Pattern p = Pattern.compile("name ?= ?\"" + name
43: + "\" .* checked ?= ?\"([^\"]*)\"");
44: Matcher m = p.matcher(body);
45: m.find();
46: String s = m.group(1);
47: return "1".equals(s) || "on".equals(s) || "yes".equals(s);
48: }
49: }
|