1 16 package com.google.gwt.i18n.rebind.util; 17 18 import com.google.gwt.dev.util.Util; 19 20 import org.apache.tapestry.util.text.LocalizedProperties; 21 22 import java.io.IOException ; 23 import java.io.InputStream ; 24 import java.util.Set ; 25 26 29 class LocalizedPropertiesResource extends AbstractResource { 30 31 static class Factory extends ResourceFactory { 32 public String getExt() { 33 return "properties"; 34 } 35 36 public AbstractResource load(InputStream m) { 37 LocalizedPropertiesResource bundle = new LocalizedPropertiesResource(m); 38 return bundle; 39 } 40 } 41 42 private LocalizedProperties props; 43 44 public LocalizedPropertiesResource(InputStream m) { 45 props = new LocalizedProperties(); 46 try { 47 props.load(m, Util.DEFAULT_ENCODING); 48 } catch (IOException e) { 49 throw new RuntimeException ("Failed to load " + this.getPath(), e); 50 } 51 } 52 53 public void addToKeySet(Set s) { 54 s.addAll(props.getPropertyMap().keySet()); 55 } 56 57 public Object handleGetObject(String key) { 58 return props.getProperty(key); 59 } 60 61 public String toString() { 62 return getPath(); 63 } 64 } 65 | Popular Tags |