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

Classes in this File | Line Coverage | Branch Coverage | Complexity
AbstractFileItemConverter |
81% | 9/11
83% | 5/6
| 2.5;2.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 org.apache.commons.fileupload.FileItem;
19 |  |
     import org.seasar.cubby.converter.ConversionHelper;
20 |  |
21 |  |
     /**
22 |  |
      * {@link FileItem}を他の型のオブジェクトに変換するクラスの抽象クラスです。
23 |  |
      *
24 |  |
      * @author baba
25 |  |
      */
26 | 38 |
     public abstract class AbstractFileItemConverter extends AbstractConverter {
27 |  |
28 |  |
             /**
29 |  |
              * {@inheritDoc}
30 |  |
              */
31 |  |
             @Override
32 |  |
             public boolean canConvert(final Class<?> parameterType,
33 |  |
                             final Class<?> objectType) {
34 | 260 |
                     if (parameterType == null) {
35 | 20 |
                             return false;
36 |  |
                     }
37 | 240 |
                     if (!FileItem.class.isAssignableFrom(parameterType)) {
38 | 226 |
                             return false;
39 |  |
                     }
40 | 14 |
                     return super.canConvert(parameterType, objectType);
41 |  |
             }
42 |  |
43 |  |
             /**
44 |  |
              * {@inheritDoc}
45 |  |
              */
46 |  |
             public Object convertToObject(final Object value,
47 |  |
                             final Class<?> objectType, final ConversionHelper helper) {
48 | 6 |
                     if (value == null) {
49 | 0 |
                             return null;
50 |  |
                     }
51 | 6 |
                     final FileItem fileItem = (FileItem) value;
52 | 6 |
                     return convert(fileItem);
53 |  |
             }
54 |  |
55 |  |
             /**
56 |  |
              * {@inheritDoc}
57 |  |
              */
58 |  |
             public String convertToString(final Object value,
59 |  |
                             final ConversionHelper helper) {
60 | 0 |
                     return null;
61 |  |
             }
62 |  |
63 |  |
             /**
64 |  |
              * {@link FileItem} を特定の型に変換します。
65 |  |
              *
66 |  |
              * @param fileItem
67 |  |
              *            変換元のインスタンス
68 |  |
              * @return <code>fileItem</code>を変換したインスタンス
69 |  |
              */
70 |  |
             protected abstract Object convert(final FileItem fileItem);
71 |  |
72 |  |
     }