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
 
 1  
 /*
 2  
  * Copyright 2004-2010 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  
 
 17  
 package org.seasar.cubby.converter.impl;
 18  
 
 19  
 import org.apache.commons.fileupload.FileItem;
 20  
 import org.seasar.cubby.converter.ConversionHelper;
 21  
 
 22  
 /**
 23  
  * {@link FileItem}を他の型のオブジェクトに変換するクラスの抽象クラスです。
 24  
  * 
 25  
  * @author baba
 26  
  */
 27  38
 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  260
                 if (parameterType == null) {
 36  20
                         return false;
 37  
                 }
 38  240
                 if (!FileItem.class.isAssignableFrom(parameterType)) {
 39  226
                         return false;
 40  
                 }
 41  14
                 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  6
                 if (value == null) {
 50  0
                         return null;
 51  
                 }
 52  6
                 final FileItem fileItem = (FileItem) value;
 53  6
                 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  
 }