1 14 package org.wings.recorder; 15 16 import java.util.regex.Matcher ; 17 import java.util.regex.Pattern ; 18 19 23 public class Response { 24 private String body; 25 26 public Response(String body) { 27 this.body = body; 28 } 29 30 public String getBody() { 31 return body; 32 } 33 34 public String getTextValue(String name) { 35 Pattern p = Pattern.compile("name ?= ?\"" + name + "\" .* 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 + "\" .* checked ?= ?\"([^\"]*)\""); 43 Matcher m = p.matcher(body); 44 m.find(); 45 String s = m.group(1); 46 return "1".equals(s) || "on".equals(s) || "yes".equals(s); 47 } 48 } 49 | Popular Tags |