Coverage Report - org.seasar.cubby.dxo.impl.RequestParameterConverterFactoryWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
RequestParameterConverterFactoryWrapper
100%
6/6
N/A
0
RequestParameterConverterFactoryWrapper$DisregardExceptionConverterWrapper
100%
6/6
N/A
0
 
 1  
 /*
 2  
  * Copyright 2004-2007 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.dxo.impl;
 17  
 
 18  
 import org.seasar.extension.dxo.converter.ConversionContext;
 19  
 import org.seasar.extension.dxo.converter.Converter;
 20  
 import org.seasar.extension.dxo.converter.ConverterFactory;
 21  
 
 22  21
 public class RequestParameterConverterFactoryWrapper implements
 23  
                 ConverterFactory {
 24  
 
 25  
         private ConverterFactory converterFactory;
 26  
 
 27  
         public void setConverterFactory(final ConverterFactory converterFactory) {
 28  21
                 this.converterFactory = converterFactory;
 29  21
         }
 30  
 
 31  
         @SuppressWarnings("unchecked")
 32  
         public Converter getConverter(final Class sourceClass, final Class destClass) {
 33  14
                 final Converter converter = converterFactory.getConverter(sourceClass,
 34  
                                 destClass);
 35  14
                 return new DisregardExceptionConverterWrapper(converter);
 36  
         }
 37  
 
 38  21
         static class DisregardExceptionConverterWrapper implements Converter {
 39  
 
 40  
                 private final Converter converter;
 41  
 
 42  14
                 public DisregardExceptionConverterWrapper(final Converter converter) {
 43  14
                         this.converter = converter;
 44  14
                 }
 45  
 
 46  
                 @SuppressWarnings("unchecked")
 47  
                 public Object convert(final Object source, final Class destClass,
 48  
                                 final ConversionContext context) {
 49  
                         try {
 50  10
                                 return converter.convert(source, destClass, context);
 51  
                         } catch (final Exception e) {
 52  
                                 return null;
 53  
                         }
 54  
                 }
 55  
 
 56  
                 public void convert(final Object source, final Object dest,
 57  
                                 final ConversionContext context) {
 58  4
                         converter.convert(source, dest, context);
 59  4
                 }
 60  
 
 61  
                 @SuppressWarnings("unchecked")
 62  
                 public Class getDestClass() {
 63  
                         return converter.getDestClass();
 64  
                 }
 65  
 
 66  
                 @SuppressWarnings("unchecked")
 67  
                 public Class[] getSourceClasses() {
 68  
                         return converter.getSourceClasses();
 69  
                 }
 70  
 
 71  
         }
 72  
 
 73  
 }