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