1 13 package com.tonbeller.wcf.format; 14 15 import java.util.List ; 16 17 20 public class DoubleHandler extends NumberHandler { 21 22 public Object parse(String s, String userPattern) throws FormatException { 23 Number n = (Number ) super.parse(s, userPattern); 24 return new Double (n.doubleValue()); 25 } 26 27 public boolean canHandle(Object value) { 28 return value instanceof Number ; 29 } 30 31 public Object toNativeArray(List list) { 32 double[] array = new double[list.size()]; 33 for (int i = 0; i < array.length; i++) 34 array[i] = ((Number )list.get(i)).doubleValue(); 35 return array; 36 } 37 38 public Object [] toObjectArray(Object value) { 39 if (value instanceof Double ) 40 return new Double []{(Double )value}; 41 double[] src = (double[])value; 42 Double [] dst = new Double [src.length]; 43 for (int i = 0; i < src.length; i++) 44 dst[i] = new Double (src[i]); 45 return dst; 46 } 47 48 } | Popular Tags |