jfun.yan.util.resource
Class OrResourceLoader

java.lang.Object
  extended by jfun.yan.util.resource.OrResourceLoader
All Implemented Interfaces:
java.io.Serializable, ResourceLoader

public class OrResourceLoader
extends java.lang.Object
implements ResourceLoader

This class represents a ResourceLoader that loads resource using a primary ResourceLoader object, and tries an alternative ResourceLoader if the primary doesn't find a resource.

Author:
Ben Yu Jan 16, 2006 4:08:55 PM
See Also:
Serialized Form

Constructor Summary
OrResourceLoader(ResourceLoader primary, ResourceLoader alt)
          Create an OrResourceLoader object.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 ResourceLoader getAlternative()
          Get the alternative resource.
 ResourceLoader getPrimary()
          Get the primary resource.
 java.net.URL getResource(java.lang.String path)
          Get the URL that identifies the resource.
 java.io.InputStream getResourceAsStream(java.lang.String path)
          Create a InputStream for a resource.
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrResourceLoader

public OrResourceLoader(ResourceLoader primary,
                        ResourceLoader alt)
Create an OrResourceLoader object.

Parameters:
primary - the primary ResourceLoader.
alt - the alternative ResourceLoader.
Method Detail

getResource

public java.net.URL getResource(java.lang.String path)
Description copied from interface: ResourceLoader
Get the URL that identifies the resource.

Specified by:
getResource in interface ResourceLoader
Parameters:
path - the resource path.
Returns:
the URL. null is returned if the path is not recognized.

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path)
Description copied from interface: ResourceLoader
Create a InputStream for a resource.

Specified by:
getResourceAsStream in interface ResourceLoader
Parameters:
path - the resource path.
Returns:
the InputStream object or null if not found.

getPrimary

public ResourceLoader getPrimary()
Get the primary resource.


getAlternative

public ResourceLoader getAlternative()
Get the alternative resource.


equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object