1 16 package scriptella.configuration; 17 18 import scriptella.util.PropertiesMap; 19 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 import java.util.Collections ; 23 import java.util.Map ; 24 25 26 32 public class PropertiesEl extends XmlConfigurableBase { 33 Map<String , ?> map = Collections.emptyMap(); 34 35 public PropertiesEl() { 36 } 37 38 public PropertiesEl(XmlElement element) { 39 configure(element); 40 } 41 42 public void configure(final XmlElement element) { 43 if (element == null) { 44 return; } 46 if (element.getElement().hasChildNodes()) { 48 PropertiesMap p = new PropertiesMap(); 49 ContentEl content = new ContentEl(element); 50 InputStream is = null; 51 52 try { 53 is = new ReaderInputStream(content.open()); 54 p.load(is); 55 map = p; 56 } catch (Exception e) { 57 throw new ConfigurationException("Unable to load properties", e, 58 element); 59 } finally { 60 if (is != null) { 61 try { 62 is.close(); 63 } catch (IOException e) { 64 } 65 } 66 } 67 } 68 } 69 70 public Map<String , ?> getMap() { 71 return map; 72 } 73 74 public void setMap(Map<String , ?> map) { 75 this.map = new PropertiesMap(map); 76 } 77 } 78 | Popular Tags |