Coverage Report - org.seasar.uruma.binding.value.command.ExportValueCommand
 
Classes in this File Line Coverage Branch Coverage Complexity
ExportValueCommand
80%
12/15
75%
6/8
0
 
 1  
 /*
 2  
  * Copyright 2004-2008 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.uruma.binding.value.command;
 17  
 
 18  
 import java.lang.reflect.Field;
 19  
 import java.util.List;
 20  
 
 21  
 import org.seasar.framework.beans.PropertyDesc;
 22  
 import org.seasar.framework.util.StringUtil;
 23  
 import org.seasar.uruma.annotation.ExportValue;
 24  
 import org.seasar.uruma.annotation.ImportExportValue;
 25  
 import org.seasar.uruma.binding.value.BindingCommand;
 26  
 import org.seasar.uruma.binding.value.ValueBinder;
 27  
 import org.seasar.uruma.component.UIComponent;
 28  
 import org.seasar.uruma.desc.FormDesc;
 29  
 
 30  
 /**
 31  
  * {@link ExportValue} アノテーションに対応した処理を行うための、{@link BindingCommand} です。<br />
 32  
  * 
 33  
  * @author y-komori
 34  
  */
 35  4
 public class ExportValueCommand extends AbstractBindingCommand<ExportValue> {
 36  
 
 37  
     /*
 38  
      * @see org.seasar.uruma.binding.value.BindingCommand#getTargetPropertyDescs(org.seasar.uruma.desc.FormDesc)
 39  
      */
 40  
     public List<PropertyDesc> getTargetPropertyDescs(final FormDesc desc) {
 41  148
         return desc.getExportValueProperties();
 42  
     }
 43  
 
 44  
     /*
 45  
      * @see org.seasar.uruma.binding.value.command.AbstractBindingCommand#doBind(org.seasar.uruma.binding.value.ValueBinder,
 46  
      *      java.lang.Object, java.lang.Object,
 47  
      *      org.seasar.framework.beans.PropertyDesc)
 48  
      */
 49  
     @Override
 50  
     protected void doBind(final ValueBinder binder, final Object widget,
 51  
             final Object formObj, final PropertyDesc propDesc,
 52  
             final UIComponent uiComp) {
 53  32
         binder.exportValue(widget, formObj, propDesc, uiComp);
 54  32
     }
 55  
 
 56  
     /*
 57  
      * @see org.seasar.uruma.binding.value.command.AbstractBindingCommand#getId(java.lang.reflect.Field)
 58  
      */
 59  
     @Override
 60  
     public String getId(final Field field) {
 61  32
         ExportValue exportValue = field.getAnnotation(ExportValue.class);
 62  32
         if (exportValue != null) {
 63  24
             String id = exportValue.id();
 64  24
             return StringUtil.isEmpty(id) ? field.getName() : id;
 65  
         }
 66  
 
 67  8
         ImportExportValue importExportValue = field
 68  
                 .getAnnotation(ImportExportValue.class);
 69  8
         if (importExportValue != null) {
 70  8
             String id = importExportValue.id();
 71  8
             return StringUtil.isEmpty(id) ? field.getName() : id;
 72  
         }
 73  
 
 74  0
         return field.getName();
 75  
     }
 76  
 
 77  
     /*
 78  
      * @see org.seasar.uruma.binding.value.command.AbstractBindingCommand#getAnnotation(Field)
 79  
      */
 80  
     @Override
 81  
     protected ExportValue getAnnotation(final Field field) {
 82  0
         return field.getAnnotation(ExportValue.class);
 83  
     }
 84  
 
 85  
     /*
 86  
      * @see org.seasar.uruma.binding.value.command.AbstractBindingCommand#getId(ANNOTATION_CLASS)
 87  
      */
 88  
     @Override
 89  
     protected String getId(final ExportValue annotation) {
 90  0
         return annotation.id();
 91  
     }
 92  
 }