1 9 10 package org.jboss.portal.format.util; 11 12 import java.io.InputStream ; 13 14 20 public class CLLoader implements Loader 21 { 22 23 private final ClassLoader cl; 24 private String base; 25 26 public CLLoader() 27 { 28 this(Thread.currentThread().getContextClassLoader(), null); 29 } 30 31 public CLLoader(ClassLoader cl, String base) 32 { 33 this.cl = cl; 34 setBase(base); 35 } 36 37 public CLLoader(ClassLoader cl) 38 { 39 this(cl, null); 40 } 41 42 public CLLoader(String base) 43 { 44 this(Thread.currentThread().getContextClassLoader(), base); 45 } 46 47 public String getBase() 48 { 49 return base; 50 } 51 52 public void setBase(String base) 53 { 54 this.base = base != null ? base : ""; 55 } 56 57 public InputStream load(String name) 58 { 59 return cl.getResourceAsStream(base.length() == 0 ? name.substring(1) : base + name); 60 } 61 } 62 | Popular Tags |