Coverage Report - org.kuali.rice.kns.util.MessageContainer
 
Classes in this File Line Coverage Branch Coverage Complexity
MessageContainer
0%
0/15
0%
0/4
1.25
 
 1  
 /*
 2  
  * Copyright 2007-2009 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
 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, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kns.util;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.Iterator;
 20  
 import java.util.List;
 21  
 import java.util.Set;
 22  
 
 23  
 import org.apache.struts.action.ActionMessage;
 24  
 import org.apache.struts.action.ActionMessages;
 25  
 
 26  
 /**
 27  
  * An adapter whose subclasses will make either an {@link MessageMap}'s warning or info messages available to the JSP layer
 28  
  * 
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  *
 31  
  */
 32  
 public abstract class MessageContainer implements Serializable {
 33  
         private MessageMap errorMap;
 34  
         
 35  0
         protected MessageContainer(MessageMap errorMap) {
 36  0
                 this.errorMap = errorMap;
 37  0
         }
 38  
         
 39  
         /**
 40  
          * @deprecated use {@link #getMessageMap()} instead
 41  
          * This method ...
 42  
          * 
 43  
          * @return
 44  
          */
 45  
         @Deprecated
 46  
         protected ErrorMap getErrorMap() {
 47  0
                 return new ErrorMap(errorMap);
 48  
         }
 49  
         
 50  
         protected MessageMap getMessageMap() {
 51  0
                 return errorMap;
 52  
         }
 53  
         
 54  
     public ActionMessages getRequestMessages() {
 55  0
         ActionMessages requestErrors = new ActionMessages();
 56  0
         for (Iterator<String> iter = getMessagePropertyNames().iterator(); iter.hasNext();) {
 57  0
             String property = iter.next();
 58  0
             List errorList = (List) getMessagesForProperty(property);
 59  
 
 60  0
             for (Iterator iterator = errorList.iterator(); iterator.hasNext();) {
 61  0
                 ErrorMessage errorMessage = (ErrorMessage) iterator.next();
 62  
 
 63  
                 // add ActionMessage with any parameters
 64  0
                 requestErrors.add(property, new ActionMessage(errorMessage.getErrorKey(), errorMessage.getMessageParameters()));
 65  0
             }
 66  0
         }
 67  0
         return requestErrors;
 68  
     }
 69  
     
 70  
     public abstract int getMessageCount();
 71  
     
 72  
     public abstract List<String> getMessagePropertyList();
 73  
 
 74  
     protected abstract Set<String> getMessagePropertyNames();
 75  
     
 76  
     protected abstract List getMessagesForProperty(String propertyName);
 77  
 }