Coverage Report - org.seasar.teeda.extension.annotation.handler.TigerTakeOverDescAnnotationHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
TigerTakeOverDescAnnotationHandler
89%
17/19
69%
11/16
0
 
 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.extension.annotation.handler;
 17  
 
 18  
 import java.lang.reflect.Method;
 19  
 import java.util.HashMap;
 20  
 import java.util.Map;
 21  
 
 22  
 import org.seasar.framework.beans.BeanDesc;
 23  
 import org.seasar.framework.container.ComponentDef;
 24  
 import org.seasar.framework.container.S2Container;
 25  
 import org.seasar.teeda.extension.annotation.takeover.TakeOver;
 26  
 import org.seasar.teeda.extension.html.TakeOverDesc;
 27  
 
 28  
 /**
 29  
  * @author higa
 30  
  * @author shot
 31  
  */
 32  3
 public class TigerTakeOverDescAnnotationHandler extends ConstantTakeOverDescAnnotationHandler {
 33  
 
 34  
     @SuppressWarnings("unchecked")
 35  
     @Override
 36  
     protected Map getTakeOverDescs(S2Container container, ComponentDef componentDef,
 37  
             Class componentClass, String componentName, BeanDesc beanDesc) {
 38  2
         Map<String, TakeOverDesc> ret = new HashMap<String, TakeOverDesc>();
 39  2
         Method[] methods = componentClass.getMethods();
 40  27
         for (int i = 0; i < methods.length; ++i) {
 41  25
             Method method = methods[i];
 42  25
             if (method.isBridge() || method.isSynthetic()) {
 43  0
                 continue;
 44  
             }
 45  25
             String methodName = method.getName();
 46  25
             if (!methodName.startsWith("do") && !methodName.startsWith("go")
 47  
                     && !methodName.startsWith("jump")) {
 48  22
                 continue;
 49  
             }
 50  3
             TakeOver takeOver = method.getAnnotation(TakeOver.class);
 51  3
             if (takeOver == null) {
 52  0
                 continue;
 53  
             }
 54  3
             TakeOverDesc takeOverDesc = createTakeOverDesc(takeOver.type().getName(), takeOver
 55  
                     .properties());
 56  3
             ret.put(methodName, takeOverDesc);
 57  
         }
 58  2
         final Map<String, TakeOverDesc> m = super.getTakeOverDescs(container, componentDef,
 59  
                 componentClass, componentName, beanDesc);
 60  2
         if (!m.isEmpty()) {
 61  1
             ret.putAll(m);
 62  
         }
 63  2
         return ret;
 64  
     }
 65  
 
 66  
 }