Coverage Report - org.seasar.teeda.core.config.faces.assembler.impl.DefaultConverterAssembler
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultConverterAssembler
100%
8/8
N/A
1.222
DefaultConverterAssembler$ConverterChildAssemblerById
75%
6/8
50%
1/2
1.222
DefaultConverterAssembler$ConverterChildAssemblerByTargetClass
70%
7/10
50%
1/2
1.222
 
 1  
 /*
 2  
  * Copyright 2004-2011 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.teeda.core.config.faces.assembler.impl;
 17  
 
 18  
 import java.util.Map;
 19  
 
 20  
 import org.seasar.framework.util.ClassUtil;
 21  
 import org.seasar.framework.util.StringUtil;
 22  
 import org.seasar.teeda.core.application.ConfigurationSupport;
 23  
 import org.seasar.teeda.core.application.ConverterConfiguration;
 24  
 import org.seasar.teeda.core.config.faces.assembler.ConverterAssembler;
 25  
 import org.seasar.teeda.core.config.faces.assembler.ConverterChildAssembler;
 26  
 import org.seasar.teeda.core.config.faces.element.ConverterElement;
 27  
 
 28  
 /**
 29  
  * @author shot
 30  
  */
 31  
 public class DefaultConverterAssembler extends ConverterAssembler {
 32  
 
 33  
     private ConverterChildAssembler converterIdAssembler_;
 34  
 
 35  
     private ConverterChildAssembler conveterClassAssembler_;
 36  
 
 37  
     public DefaultConverterAssembler(Map convertersByClass, Map convertersById) {
 38  4
         super(convertersByClass, convertersById);
 39  4
     }
 40  
 
 41  
     protected void setupBeforeAssemble() {
 42  4
         converterIdAssembler_ = new ConverterChildAssemblerById(
 43  
                 getConvertersById());
 44  4
         conveterClassAssembler_ = new ConverterChildAssemblerByTargetClass(
 45  
                 getConvertersByClass());
 46  4
     }
 47  
 
 48  
     public void assemble() {
 49  4
         converterIdAssembler_.assemble();
 50  4
         conveterClassAssembler_.assemble();
 51  4
     }
 52  
 
 53  
     private static class ConverterChildAssemblerById extends
 54  
             ConverterChildAssembler {
 55  
 
 56  
         public ConverterChildAssemblerById(Map targetConverters) {
 57  4
             super(targetConverters);
 58  4
         }
 59  
 
 60  
         protected void doAssemble(String converterId,
 61  
                 ConverterElement converterElement) {
 62  2
             String converterClass = converterElement.getConverterClass();
 63  2
             if (!StringUtil.isEmpty(converterClass)) {
 64  2
                 getApplication().addConverter(converterId, converterClass);
 65  
             }
 66  2
         }
 67  
 
 68  
         protected void doAddConverterConfiguration(
 69  
                 ConfigurationSupport support, String converterKey,
 70  
                 ConverterConfiguration configuration) {
 71  0
             support.addConverterConfiguration(converterKey, configuration);
 72  0
         }
 73  
     }
 74  
 
 75  
     private static class ConverterChildAssemblerByTargetClass extends
 76  
             ConverterChildAssembler {
 77  
 
 78  
         public ConverterChildAssemblerByTargetClass(Map targetConverters) {
 79  4
             super(targetConverters);
 80  4
         }
 81  
 
 82  
         protected void doAssemble(String converterForClass,
 83  
                 ConverterElement converterElement) {
 84  2
             String converterClass = converterElement.getConverterClass();
 85  2
             if (!StringUtil.isEmpty(converterClass)) {
 86  2
                 Class targetClazz = ClassUtil.forName(converterForClass);
 87  2
                 getApplication().addConverter(targetClazz, converterClass);
 88  
             }
 89  2
         }
 90  
 
 91  
         protected void doAddConverterConfiguration(
 92  
                 ConfigurationSupport support, String converterForClass,
 93  
                 ConverterConfiguration configuration) {
 94  0
             Class targetClazz = ClassUtil.forName(converterForClass);
 95  0
             support.addConverterConfiguration(targetClazz, configuration);
 96  0
         }
 97  
     }
 98  
 
 99  
 }