1 package com.leonarduk.clearcheckbook.dto; 2 3 import com.gargoylesoftware.htmlunit.util.NameValuePair; 4 5 /*** 6 * This is a special work-around to convert boolean values to 1 or 0 rather than 7 * true or false. 8 * 9 * @author Stephen Leonard 10 * @since 30 Jan 2014 11 * 12 * @version $Author:: $: Author of last commit 13 * @version $Rev:: $: Revision of last commit 14 * @version $Date:: $: Date of last commit 15 * 16 */ 17 public class ParsedNameValuePair extends NameValuePair { 18 19 private boolean isBoolean; 20 21 22 /*** 23 * This is a special work-around to convert boolean values to 1 or 0 rather 24 * than true or false. 25 * 26 * @param name 27 * @param value 28 */ 29 public ParsedNameValuePair(String name, String value) { 30 super(name, value); 31 this.isBoolean = (null != value && (value.equalsIgnoreCase("true") || value 32 .equalsIgnoreCase("false"))); 33 } 34 35 @Override 36 public String toString() { 37 if (this.isBoolean) { 38 return "Boolean value: " + super.toString(); 39 } 40 return super.toString(); 41 } 42 43 @Override 44 public String getValue() { 45 String value = super.getValue(); 46 if (this.isBoolean) { 47 if (Boolean.valueOf(value)) { 48 return "1"; 49 } 50 return "0"; 51 } 52 return value; 53 } 54 55 /*** 56 * 57 */ 58 private static final long serialVersionUID = 895202581659046934L; 59 60 }