Coverage Report - org.seasar.teeda.extension.annotation.handler.TigerFacesMessageAnnotationHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
TigerFacesMessageAnnotationHandler
100%
16/16
100%
6/6
4
 
 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.Field;
 19  
 import java.util.Map;
 20  
 
 21  
 import javax.faces.application.FacesMessage;
 22  
 
 23  
 import org.seasar.framework.beans.BeanDesc;
 24  
 import org.seasar.framework.util.StringUtil;
 25  
 import org.seasar.framework.util.tiger.AnnotationUtil;
 26  
 import org.seasar.teeda.extension.annotation.message.MessageAggregation;
 27  
 
 28  
 /**
 29  
  * @author shot
 30  
  * 
 31  
  */
 32  3
 public class TigerFacesMessageAnnotationHandler extends
 33  
                 ConstantFacesMessageAnnotationHandler {
 34  
 
 35  
         protected void processField(String componentName, BeanDesc beanDesc,
 36  
                         Field field) {
 37  3
                 MessageAggregation annotation = field
 38  
                                 .getAnnotation(MessageAggregation.class);
 39  3
                 if (annotation != null) {
 40  2
                         Map props = AnnotationUtil.getProperties(annotation);
 41  2
                         String id = (String) props.remove("id");
 42  2
                         FacesMessage facesMessage = null;
 43  2
                         facesMessage = createFacesMessage(id);
 44  2
                         String summary = (String) props.remove("summary");
 45  2
                         if (!StringUtil.isEmpty(summary)) {
 46  1
                 facesMessage.setSummary(summary);
 47  
                         }
 48  2
                         String detail = (String) props.remove("detail");
 49  2
                         if (!StringUtil.isEmpty(detail)) {
 50  1
                 facesMessage.setDetail(detail);
 51  
                         }
 52  2
                         registerFacesMessage(componentName, field.getName(), facesMessage);
 53  
                 }
 54  3
                 super.processField(componentName, beanDesc, field);
 55  3
         }
 56  
 
 57  
 }