Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractFileItemConverter |
|
| 0.0;0 |
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 | * @since 1.1.0 | |
26 | */ | |
27 | 114 | public abstract class AbstractFileItemConverter extends AbstractConverter { |
28 | ||
29 | /** | |
30 | * {@inheritDoc} | |
31 | */ | |
32 | @Override | |
33 | public boolean canConvert(final Class<?> parameterType, | |
34 | final Class<?> objectType) { | |
35 | 780 | if (parameterType == null) { |
36 | 60 | return false; |
37 | } | |
38 | 720 | if (!FileItem.class.isAssignableFrom(parameterType)) { |
39 | 678 | return false; |
40 | } | |
41 | 42 | return super.canConvert(parameterType, objectType); |
42 | } | |
43 | ||
44 | /** | |
45 | * {@inheritDoc} | |
46 | */ | |
47 | public Object convertToObject(final Object value, | |
48 | final Class<?> objectType, final ConversionHelper helper) { | |
49 | 18 | if (value == null) { |
50 | 0 | return null; |
51 | } | |
52 | 18 | final FileItem fileItem = (FileItem) value; |
53 | 18 | return convert(fileItem); |
54 | } | |
55 | ||
56 | /** | |
57 | * {@inheritDoc} | |
58 | */ | |
59 | public String convertToString(final Object value, | |
60 | final ConversionHelper helper) { | |
61 | 0 | return null; |
62 | } | |
63 | ||
64 | /** | |
65 | * {@link FileItem} を特定の型に変換します。 | |
66 | * | |
67 | * @param fileItem | |
68 | * 変換元のインスタンス | |
69 | * @return <code>fileItem</code>を変換したインスタンス | |
70 | */ | |
71 | protected abstract Object convert(final FileItem fileItem); | |
72 | ||
73 | } |