Coverage Report - org.kuali.rice.kns.web.struts.action.KualiPropertyMessageResources
 
Classes in this File Line Coverage Branch Coverage Complexity
KualiPropertyMessageResources
0%
0/22
0%
0/12
2.75
 
 1  
 /*
 2  
  * Copyright 2010 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.web.struts.action;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.apache.struts.util.MessageResourcesFactory;
 20  
 import org.apache.struts.util.PropertyMessageResources;
 21  
 
 22  
 import java.util.HashMap;
 23  
 import java.util.Map;
 24  
 import java.util.Set;
 25  
 
 26  
 /**
 27  
  * This is a description of what this class does - jjhanso don't forget to fill this in. 
 28  
  * 
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  *
 31  
  */
 32  
 public class KualiPropertyMessageResources extends PropertyMessageResources {
 33  
     private static final long serialVersionUID = -7712311580595112293L;
 34  
     private HashMap kualiMessages;
 35  
 
 36  
     public KualiPropertyMessageResources(MessageResourcesFactory factory, String config) {
 37  0
         super(factory, config);
 38  0
     }
 39  
 
 40  
     public KualiPropertyMessageResources(MessageResourcesFactory factory, String config, boolean returnNull) {
 41  0
         super(factory, config, returnNull);
 42  0
     }
 43  
 
 44  
     protected void loadLocale(String localeKey) {
 45  0
         String initialConfig = config;
 46  0
         String[] propertyFiles = config.split(",");
 47  0
         for (String propertyFile : propertyFiles) {
 48  0
             config = propertyFile;
 49  0
             locales.remove(localeKey);
 50  0
             super.loadLocale(localeKey);
 51  
         }
 52  0
         config = initialConfig;
 53  0
     }
 54  
     
 55  
     public Map getKualiProperties(String localeKey) {
 56  0
         if (this.kualiMessages != null && !this.kualiMessages.isEmpty()) {
 57  0
             return this.kualiMessages;
 58  
         } 
 59  0
         localeKey = (localeKey == null) ? "" : localeKey;
 60  0
         String localePrefix = localeKey + ".";
 61  
         
 62  0
         this.loadLocale((localeKey == null) ? "" : localeKey);
 63  0
         this.kualiMessages = new HashMap(this.messages.size());
 64  0
         Set<String> keys = this.messages.keySet();
 65  0
         for (String key : keys) {
 66  0
             this.kualiMessages.put(StringUtils.substringAfter(key, localePrefix), this.messages.get(key));
 67  
         }
 68  0
         return this.kualiMessages;
 69  
     }
 70  
 
 71  
 }