public class ResourceFinder extends Object
Constructor and Description |
---|
ResourceFinder(String path) |
ResourceFinder(String path,
ClassLoaderInterface classLoaderInterface) |
ResourceFinder(String path,
ClassLoaderInterface classLoaderInterface,
URL... urls) |
ResourceFinder(String path,
URL... urls) |
ResourceFinder(URL... urls) |
Modifier and Type | Method and Description |
---|---|
URL |
find(String uri) |
List<URL> |
findAll(String uri) |
List<Class> |
findAllClasses(String uri)
Executes findAllStrings assuming the strings are
the names of a classes that should be loaded and returned.
|
List<Class> |
findAllImplementations(Class interfase)
Assumes the class specified points to a file in the classpath that contains
the name of a class that implements or is a subclass of the specfied class.
|
List<Properties> |
findAllProperties(String uri)
Finds the corresponding resources and reads them in as a properties files
Any URL that cannot be read in as a properties file will cause an exception to be thrown.
|
List<String> |
findAllStrings(String uri)
Reads the contents of the found URLs as a list of
String 's and returns them. |
List<Class> |
findAvailableClasses(String uri)
Executes findAvailableStrings assuming the strings are
the names of a classes that should be loaded and returned.
|
List<Class> |
findAvailableImplementations(Class interfase)
Assumes the class specified points to a file in the classpath that contains
the name of a class that implements or is a subclass of the specfied class.
|
List<Properties> |
findAvailableProperties(String uri)
Finds the corresponding resources and reads them in as a properties files
Any URL that cannot be read in as a properties file will be added to the
'resourcesNotLoaded' collection.
|
List<String> |
findAvailableStrings(String uri)
Reads the contents of the found URLs as a Strings and returns them.
|
Class |
findClass(String uri)
Executes
findString(String) assuming the contents URL found is the name of
a class that should be loaded and returned. |
Class |
findImplementation(Class interfase)
Assumes the class specified points to a file in the classpath that contains
the name of a class that implements or is a subclass of the specfied class.
|
Set<String> |
findPackages(String uri)
Gets a list of subpckages from jars or dirs
|
Map<URL,Set<String>> |
findPackagesMap(String uri)
Gets a list of subpckages from jars or dirs
|
Properties |
findProperties(String uri)
Finds the corresponding resource and reads it in as a properties file
Example classpath:
META-INF/widget.properties
ResourceFinder finder = new ResourceFinder("META-INF/");
Properties widgetProps = finder.findProperties("widget.properties");
|
String |
findString(String uri)
Reads the contents of the URL as a
String 's and returns it. |
Map<String,URL> |
getResourcesMap(String uri) |
List<String> |
getResourcesNotLoaded()
Returns a list of resources that could not be loaded in the last invoked findAvailable* or
mapAvailable* methods.
|
Map<String,Class> |
mapAllClasses(String uri)
Executes mapAllStrings assuming the value of each entry in the
map is the name of a class that should be loaded.
|
Map<String,Class> |
mapAllImplementations(Class interfase)
Assumes the class specified points to a directory in the classpath that holds files
containing the name of a class that implements or is a subclass of the specfied class.
|
Map<String,Properties> |
mapAllProperties(String uri)
Finds the corresponding resources and reads them in as a properties files
Any URL that cannot be read in as a properties file will cause an exception to be thrown.
|
Map<String,String> |
mapAllStrings(String uri)
Reads the contents of all non-directory URLs immediately under the specified
location and returns them in a map keyed by the file name.
|
Map<String,Class> |
mapAvailableClasses(String uri)
Executes mapAvailableStrings assuming the value of each entry in the
map is the name of a class that should be loaded.
|
Map<String,Class> |
mapAvailableImplementations(Class interfase)
Assumes the class specified points to a directory in the classpath that holds files
containing the name of a class that implements or is a subclass of the specfied class.
|
Map<String,Properties> |
mapAvailableProperties(String uri)
Finds the corresponding resources and reads them in as a properties files
Any URL that cannot be read in as a properties file will be added to the
'resourcesNotLoaded' collection.
|
Map<String,String> |
mapAvailableStrings(String uri)
Reads the contents of all non-directory URLs immediately under the specified
location and returns them in a map keyed by the file name.
|
public ResourceFinder(URL... urls)
public ResourceFinder(String path)
public ResourceFinder(String path, ClassLoaderInterface classLoaderInterface)
public ResourceFinder(String path, ClassLoaderInterface classLoaderInterface, URL... urls)
public List<String> getResourcesNotLoaded()
public URL find(String uri) throws IOException
IOException
public List<URL> findAll(String uri) throws IOException
IOException
public String findString(String uri) throws IOException
String
's and returns it.uri
- IOException
- if a resource pointed out by the uri param could not be findClassLoader.getResource(String)
public List<String> findAllStrings(String uri) throws IOException
String
's and returns them.uri
- IOException
- if any of the found URLs are unable to be read.public List<String> findAvailableStrings(String uri) throws IOException
uri
- IOException
- if classLoader.getResources throws an exceptionpublic Map<String,String> mapAllStrings(String uri) throws IOException
uri
- IOException
- if any of the urls cannot be readpublic Map<String,String> mapAvailableStrings(String uri) throws IOException
uri
- IOException
- if classLoader.getResources throws an exceptionpublic Class findClass(String uri) throws IOException, ClassNotFoundException
findString(String)
assuming the contents URL found is the name of
a class that should be loaded and returned.uri
- IOException
ClassNotFoundException
public List<Class> findAllClasses(String uri) throws IOException, ClassNotFoundException
uri
- IOException
ClassNotFoundException
public List<Class> findAvailableClasses(String uri) throws IOException
uri
- IOException
- if classLoader.getResources throws an exceptionpublic Map<String,Class> mapAllClasses(String uri) throws IOException, ClassNotFoundException
uri
- IOException
ClassNotFoundException
public Map<String,Class> mapAvailableClasses(String uri) throws IOException
uri
- IOException
- if classLoader.getResources throws an exceptionpublic Class findImplementation(Class interfase) throws IOException, ClassNotFoundException
interfase
- a superclass or interfaceIOException
- if the URL cannot be readClassNotFoundException
- if the class found is not loadableClassCastException
- if the class found is not assignable to the specified superclass or interfacepublic List<Class> findAllImplementations(Class interfase) throws IOException, ClassNotFoundException
interfase
- a superclass or interfaceIOException
- if the URL cannot be readClassNotFoundException
- if the class found is not loadableClassCastException
- if the class found is not assignable to the specified superclass or interfacepublic List<Class> findAvailableImplementations(Class interfase) throws IOException
interfase
- a superclass or interfaceIOException
- if classLoader.getResources throws an exceptionpublic Map<String,Class> mapAllImplementations(Class interfase) throws IOException, ClassNotFoundException
interfase
- a superclass or interfaceIOException
- if the URL cannot be readClassNotFoundException
- if the class found is not loadableClassCastException
- if the class found is not assignable to the specified superclass or interfacepublic Map<String,Class> mapAvailableImplementations(Class interfase) throws IOException
interfase
- a superclass or interfaceIOException
- if classLoader.getResources throws an exceptionpublic Properties findProperties(String uri) throws IOException
uri
- IOException
- if the URL cannot be read or is not in properties file formatpublic List<Properties> findAllProperties(String uri) throws IOException
uri
- IOException
- if the URL cannot be read or is not in properties file formatpublic List<Properties> findAvailableProperties(String uri) throws IOException
uri
- IOException
- if classLoader.getResources throws an exceptionpublic Map<String,Properties> mapAllProperties(String uri) throws IOException
uri
- IOException
- if the URL cannot be read or is not in properties file formatpublic Map<String,Properties> mapAvailableProperties(String uri) throws IOException
uri
- IOException
- if classLoader.getResources throws an exceptionpublic Map<String,URL> getResourcesMap(String uri) throws IOException
IOException
public Set<String> findPackages(String uri) throws IOException
IOException
public Map<URL,Set<String>> findPackagesMap(String uri) throws IOException
IOException
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.