1 package com.calipso.reportgenerator.common; 2 3 import org.apache.commons.configuration.Configuration; 4 5 import java.util.Iterator ; 6 import java.util.Map ; 7 import java.util.HashMap ; 8 9 import com.calipso.reportgenerator.common.LanguageTraslator; 10 import com.calipso.reportgenerator.common.ILanguageTraslator; 11 12 19 20 public class LanguageTraslatorCustomizable implements ILanguageTraslator{ 21 22 private Map values; 23 24 29 public LanguageTraslatorCustomizable(Configuration configuration) throws InfoException { 30 fillValues(configuration); 31 validate(); 32 } 33 34 39 public Map getValues() { 40 if (values==null){ 41 values = new HashMap (); 42 } 43 return values; 44 } 45 46 50 private void fillValues(Configuration reportGeneratorConfiguration) { 51 Iterator iter = reportGeneratorConfiguration.getKeys(); 52 while (iter.hasNext()) { 53 String key = (String ) iter.next(); 54 String value = reportGeneratorConfiguration.getString(key); 55 getValues().put(key,value); 56 } 57 } 58 59 63 public void validate() throws InfoException { 64 if (values.isEmpty()){ 65 throw new InfoException(LanguageTraslator.traslate("81")); 66 } 67 } 68 69 75 public String getExceptionFromId(String id){ 76 return (String ) values.get(id); 77 } 78 } 79 | Popular Tags |