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