1 16 17 package org.apache.commons.beanutils.locale.converters; 18 19 20 import java.text.ParseException ; 21 import java.util.Locale ; 22 23 24 34 35 public class DoubleLocaleConverter extends DecimalLocaleConverter { 36 37 38 40 48 public DoubleLocaleConverter() { 49 50 this(false); 51 } 52 53 61 public DoubleLocaleConverter(boolean locPattern) { 62 63 this(Locale.getDefault(), locPattern); 64 } 65 66 73 public DoubleLocaleConverter(Locale locale) { 74 75 this(locale, false); 76 } 77 78 86 public DoubleLocaleConverter(Locale locale, boolean locPattern) { 87 88 this(locale, (String ) null, locPattern); 89 } 90 91 99 public DoubleLocaleConverter(Locale locale, String pattern) { 100 101 this(locale, pattern, false); 102 } 103 104 113 public DoubleLocaleConverter(Locale locale, String pattern, boolean locPattern) { 114 115 super(locale, pattern, locPattern); 116 } 117 118 127 public DoubleLocaleConverter(Object defaultValue) { 128 129 this(defaultValue, false); 130 } 131 132 141 public DoubleLocaleConverter(Object defaultValue, boolean locPattern) { 142 143 this(defaultValue, Locale.getDefault(), locPattern); 144 } 145 146 154 public DoubleLocaleConverter(Object defaultValue, Locale locale) { 155 156 this(defaultValue, locale, false); 157 } 158 159 168 public DoubleLocaleConverter(Object defaultValue, Locale locale, boolean locPattern) { 169 170 this(defaultValue, locale, null, locPattern); 171 } 172 173 182 public DoubleLocaleConverter(Object defaultValue, Locale locale, String pattern) { 183 184 this(defaultValue, locale, pattern, false); 185 } 186 187 197 public DoubleLocaleConverter(Object defaultValue, Locale locale, String pattern, boolean locPattern) { 198 199 super(defaultValue, locale, pattern); 200 } 201 202 protected Object parse(Object value, String pattern) throws ParseException { 203 Number result = (Number ) super.parse(value, pattern); 204 if (result instanceof Long ) { 205 return new Double (result.doubleValue()); 206 } else { 207 return (result); 208 } 209 } 210 211 212 } 213 214 215 | Popular Tags |