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