Package org.zkoss.util.resource
Class ClassLocator
java.lang.Object
org.zkoss.util.resource.ClassLocator
- All Implemented Interfaces:
Locator,XMLResourcesLocator
The locator searches the current thread's context class loader,
and then this class's class loader.
It is important to use this locator if you want to load something in other jar files.
Since this locator is used frequently, Locators.getDefault()
is provided to return an instance of this class,
- Author:
- tomyeh
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.zkoss.util.resource.XMLResourcesLocator
XMLResourcesLocator.Resource -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleangetDependentXMLResources(String name, String elName, String elDepends) Returns a list of resources (XMLResourcesLocator.Resource) after resolving the dependence.Always returns null.getResource(String name) Finds the resource with the given name.getResourceAsStream(String name) Returns an input stream for reading the specified resource.getResources(String name) Returns an enumeration of resources.inthashCode()
-
Constructor Details
-
ClassLocator
public ClassLocator()
-
-
Method Details
-
getResources
Description copied from interface:XMLResourcesLocatorReturns an enumeration of resources. UnlikeXMLResourcesLocator.getDependentXMLResources(java.lang.String, java.lang.String, java.lang.String), it doesn't resolve the dependence among the resources.- Specified by:
getResourcesin interfaceXMLResourcesLocator- Parameters:
name- the resource name, such as "metainfo/config.xml".- Throws:
IOException
-
getDependentXMLResources
public List<XMLResourcesLocator.Resource> getDependentXMLResources(String name, String elName, String elDepends) throws IOException Description copied from interface:XMLResourcesLocatorReturns a list of resources (XMLResourcesLocator.Resource) after resolving the dependence. The resource is returned in the format ofXMLResourcesLocator.ResourceTo resolve the dependence, it assumes each resource has two element whose name is identified by elName and elDepends. The elName element specifies the unique name of each resource. The elDepends element specifies a list of names of resources that this resource depends on. If not found, it assumes it could be loaded first.
- Specified by:
getDependentXMLResourcesin interfaceXMLResourcesLocator- Parameters:
name- the resource name, such as "metainfo/config.xml".elName- the element used to specify the name.elDepends- the element used to specify the dependence.- Returns:
- a list of
XMLResourcesLocator.Resourceof the specified name. - Throws:
IOException
-
getDirectory
Always returns null.- Specified by:
getDirectoryin interfaceLocator
-
getResource
Description copied from interface:LocatorFinds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.- Specified by:
getResourcein interfaceLocator- Returns:
- a URL for reading the resource, or null if the resource could not be found or the caller doesn't have adequate privileges to get the resource
-
getResourceAsStream
Description copied from interface:LocatorReturns an input stream for reading the specified resource.- Specified by:
getResourceAsStreamin interfaceLocator- Returns:
- an input stream for reading the resource, or null if the resource could not be found or the caller doesn't have adequate privileges to get the resource
-
hashCode
public int hashCode() -
equals
-