##### Coverage Report - org.seasar.cubby.converter.impl.AbstractConverter

Classes in this File | Line Coverage | Branch Coverage | Complexity
AbstractConverter |
100% | 17/17
100% | 4/4
| 5.0;5

1 |  |
     /*
2 |  |
      * Copyright 2004-2009 the Seasar Foundation and the Others.
3 |  |
      *
4 |  |
      * Licensed under the Apache License, Version 2.0 (the "License");
5 |  |
      * you may not use this file except in compliance with the License.
6 |  |
      * You may obtain a copy of the License at
7 |  |
      *
8 |  |
      *     http://www.apache.org/licenses/LICENSE-2.0
9 |  |
      *
10 |  |
      * Unless required by applicable law or agreed to in writing, software
11 |  |
      * distributed under the License is distributed on an "AS IS" BASIS,
12 |  |
      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 |  |
      * either express or implied. See the License for the specific language
14 |  |
      * governing permissions and limitations under the License.
15 |  |
      */
16 |  |
     package org.seasar.cubby.converter.impl;
17 |  |
18 |  |
     import java.util.HashMap;
19 |  |
     import java.util.Map;
20 |  |
21 |  |
     import org.seasar.cubby.converter.Converter;
22 |  |
23 |  |
     /**
24 |  |
      * {@link Converter} の抽象クラスです。
25 |  |
      *
26 |  |
      * @author baba
27 |  |
      */
28 | 323 |
     public abstract class AbstractConverter implements Converter {
29 |  |
30 |  |
             /** プリミティブ型の配列クラスとラッパー型の配列クラスのマッピング */
31 | 1 |
             private static final Map<Class<?>, Class<?>> PRIMITIVE_ARRAY_TO_WRAPPER_ARRAY = new HashMap<Class<?>, Class<?>>();
32 |  |
             static {
33 | 1 |
                     PRIMITIVE_ARRAY_TO_WRAPPER_ARRAY.put(boolean[].class, Boolean[].class);
34 | 1 |
                     PRIMITIVE_ARRAY_TO_WRAPPER_ARRAY.put(char[].class, Character[].class);
35 | 1 |
                     PRIMITIVE_ARRAY_TO_WRAPPER_ARRAY.put(byte[].class, Byte[].class);
36 | 1 |
                     PRIMITIVE_ARRAY_TO_WRAPPER_ARRAY.put(short[].class, Short[].class);
37 | 1 |
                     PRIMITIVE_ARRAY_TO_WRAPPER_ARRAY.put(int[].class, Integer[].class);
38 | 1 |
                     PRIMITIVE_ARRAY_TO_WRAPPER_ARRAY.put(long[].class, Long[].class);
39 | 1 |
                     PRIMITIVE_ARRAY_TO_WRAPPER_ARRAY.put(float[].class, Float[].class);
40 | 1 |
                     PRIMITIVE_ARRAY_TO_WRAPPER_ARRAY.put(double[].class, Double[].class);
41 | 1 |
             }
42 |  |
43 |  |
             /**
44 |  |
              * {@inheritDoc}
45 |  |
              */
46 |  |
             public boolean canConvert(final Class<?> parameterType,
47 |  |
                             final Class<?> objectType) {
48 | 2189 |
                     if (getObjectType().isAssignableFrom(objectType)) {
49 | 78 |
                             return true;
50 |  |
                     }
51 | 2111 |
                     if (PRIMITIVE_ARRAY_TO_WRAPPER_ARRAY.containsKey(objectType)) {
52 | 242 |
                             final Class<?> wrapperArray = PRIMITIVE_ARRAY_TO_WRAPPER_ARRAY
53 |  |
                                             .get(objectType);
54 | 242 |
                             return canConvert(parameterType, wrapperArray);
55 |  |
                     }
56 | 1869 |
                     return false;
57 |  |
             }
58 |  |
59 |  |
     }