1 13 package com.tonbeller.wcf.format; 14 15 import java.util.List ; 16 17 18 21 public class BooleanHandler extends FormatHandlerSupport { 22 26 public String format(Object o, String userPattern) { 27 if (o == null) { 28 return "false"; 29 } 30 31 return ((Boolean ) o).toString(); 32 } 33 34 public Object parse(String s, String userPattern) { 35 return new Boolean (s); 36 } 37 38 public boolean canHandle(Object value) { 39 return value instanceof Boolean ; 40 } 41 42 public Object toNativeArray(List list) { 43 boolean[] array = new boolean[list.size()]; 44 for (int i = 0; i < array.length; i++) 45 array[i] = ((Boolean )list.get(i)).booleanValue(); 46 return array; 47 } 48 49 public Object [] toObjectArray(Object value) { 50 if (value instanceof Boolean ) 51 return new Boolean []{(Boolean )value}; 52 boolean[] src = (boolean[])value; 53 Boolean [] dst = new Boolean [src.length]; 54 for (int i = 0; i < src.length; i++) 55 dst[i] = new Boolean (src[i]); 56 return dst; 57 } 58 59 } | Popular Tags |