Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
InputStreamFileItemConverter |
|
| 0.0;0 |
1 | /* | |
2 | * Copyright 2004-2008 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.io.IOException; | |
19 | import java.io.InputStream; | |
20 | ||
21 | import org.apache.commons.fileupload.FileItem; | |
22 | import org.seasar.cubby.converter.Converter; | |
23 | import org.seasar.framework.log.Logger; | |
24 | ||
25 | /** | |
26 | * {@link FileItem}から{@link InputStream}へ変換する{@link Converter}です。 | |
27 | * | |
28 | * @author baba | |
29 | * @since 1.1.0 | |
30 | */ | |
31 | 76 | public class InputStreamFileItemConverter extends AbstractFileItemConverter { |
32 | ||
33 | /** ロガー。 */ | |
34 | 1 | private static final Logger logger = Logger |
35 | .getLogger(InputStreamFileItemConverter.class); | |
36 | ||
37 | /** | |
38 | * {@inheritDoc} | |
39 | * | |
40 | * @return {@link InputStream}のクラスを返します。 | |
41 | */ | |
42 | public Class<?> getObjectType() { | |
43 | 7 | return InputStream.class; |
44 | } | |
45 | ||
46 | /** | |
47 | * {@inheritDoc} | |
48 | * <p> | |
49 | * 指定された{@link FileItem}から取得した{@link InputStream}を返します。変換時に{@link IOException}が発生した場合は | |
50 | * <code>null</code> を返します。 | |
51 | * </p> | |
52 | * | |
53 | * @return 指定された{@link FileItem}から取得した{@link InputStream} | |
54 | * @see FileItem#getInputStream() | |
55 | */ | |
56 | @Override | |
57 | protected Object convert(final FileItem fileItem) { | |
58 | try { | |
59 | 1 | return fileItem.getInputStream(); |
60 | 0 | } catch (final IOException e) { |
61 | 0 | logger.log(e); |
62 | 0 | return null; |
63 | } | |
64 | } | |
65 | ||
66 | } |