KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > util > resource > ResourceLoaders


1 package jfun.yan.util.resource;
2
3 /**
4  * Facade class providing some useful ResourceLoader implementations.
5  * <p>
6  * @author Ben Yu
7  * Jan 17, 2006 1:47:20 PM
8  */

9 public class ResourceLoaders {
10   /**
11    * Adapt a ClassLoader to ResourceLoader.
12    * @param cloader the ClassLoader object.
13    * @return the result ResourceLoader object.
14    */

15   public static ResourceLoader toResourceLoader(ClassLoader JavaDoc cloader){
16     return new ClassLoader2ResourceLoader(cloader);
17   }
18   /**
19    * Create a ResourceLoader that
20    * loads resource using a primary ResourceLoader object,
21    * and tries an alternative ResourceLoader if the primary doesn't
22    * find a resource.
23    * @param primary the primary ResourceLoader.
24    * @param alt the alternative ResourceLoader.
25    * @return the result ResourceLoader.
26    */

27   public static ResourceLoader or(ResourceLoader primary, ResourceLoader alt){
28     return new OrResourceLoader(primary, alt);
29   }
30   /**
31    * Create a ResourceLoader that
32    * loads resource using a primary ClassLoader object,
33    * and tries an alternative ResourceLoader if the primary doesn't
34    * find a resource.
35    * @param primary the primary ClassLoader.
36    * @param alt the alternative ResourceLoader.
37    * @return the result ResourceLoader.
38    */

39   public static ResourceLoader or(ClassLoader JavaDoc primary, ResourceLoader alt){
40     return or(toResourceLoader(primary), alt);
41   }
42   /**
43    * Create a ResourceLoader that
44    * loads resource using a primary ResourceLoader object,
45    * and tries an alternative ClassLoader if the primary doesn't
46    * find a resource.
47    * @param primary the primary ResourceLoader.
48    * @param alt the alternative ClassLoader.
49    * @return the result ResourceLoader.
50    */

51   public static ResourceLoader or(ResourceLoader primary, ClassLoader JavaDoc alt){
52     return or(primary, toResourceLoader(alt));
53   }
54 }
55
Popular Tags