1 15 package org.apache.tapestry.services.impl; 16 17 import java.util.Locale ; 18 19 import org.apache.hivemind.util.Defense; 20 import org.apache.hivemind.util.LocalizedNameGenerator; 21 import org.apache.tapestry.engine.IPropertySource; 22 23 33 public class LocalizedPropertySource 34 { 35 private IPropertySource _source; 36 37 public LocalizedPropertySource(IPropertySource source) 38 { 39 Defense.notNull(source, "source"); 40 41 _source = source; 42 } 43 44 53 54 public String getPropertyValue(String propertyName, Locale locale) 55 { 56 Defense.notNull(propertyName, "propertyName"); 57 58 LocalizedNameGenerator g = new LocalizedNameGenerator(propertyName, locale, ""); 59 60 while (g.more()) 61 { 62 String localizedName = g.next(); 63 64 String result = _source.getPropertyValue(localizedName); 65 66 if (result != null) 67 return result; 68 } 69 70 return null; 71 } 72 } | Popular Tags |