1 11 package org.jboss.portlet.forums.properties; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 import java.util.HashMap ; 16 import java.util.Iterator ; 17 import java.util.Map ; 18 import java.util.Properties ; 19 20 import org.jboss.portlet.forums.ForumsConstants; 21 import org.jboss.portal.common.util.Tools; 22 23 27 public class TCCLXProperties 28 extends XProperties 29 { 30 private Map props = new HashMap (); 31 private Map urls = new HashMap (); 32 33 41 public TCCLXProperties(String base, 42 String name) 43 throws IOException 44 { 45 this(Thread.currentThread().getContextClassLoader(), base, name); 46 } 47 48 57 public TCCLXProperties(ClassLoader loader, 58 String base, 59 String name) 60 throws IOException 61 { 62 InputStream in = null; 63 try 64 { 65 in = loader.getResourceAsStream(base + "/" + name); 67 68 Properties temp = new Properties (); 70 temp.load(in); 71 props.putAll(temp); 72 73 for (Iterator i = props.entrySet().iterator(); i.hasNext();) 77 { 78 Map.Entry entry = (Map.Entry ) i.next(); 79 80 urls.put(entry.getKey(), 82 "/portal-forums/" + ForumsConstants.THEMENAME + "/" + entry.getValue()); 83 } 84 } 85 finally 86 { 87 Tools.safeClose(in); 88 } 89 } 90 91 98 public String getProperty(String name) 99 { 100 Object value = props.get(name); 101 return (value != null) ? (String ) value : ""; 102 } 103 104 111 public String getResourceURL(String name) 112 { 113 Object value = urls.get(name); 114 return (value != null) ? (String ) value : ""; 115 } 116 } | Popular Tags |