Class AbstractResourceLoader<S>
- java.lang.Object
-
- fr.ens.biologie.genomique.eoulsan.util.AbstractResourceLoader<S>
-
- Type Parameters:
S- Type of the data to load
- All Implemented Interfaces:
ResourceLoader<S>
- Direct Known Subclasses:
ClassPathResourceLoader,FileResourceLoader
public abstract class AbstractResourceLoader<S> extends Object implements ResourceLoader<S>
This class define an abstract resource loader.- Since:
- 2.0
- Author:
- Laurent Jourdren
-
-
Constructor Summary
Constructors Constructor Description AbstractResourceLoader()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddResource(String resourceName, String resourcePath)Add a resource.protected abstract InputStreamgetResourceAsStream(String resourcePath)Get the input stream related to a resource.protected abstract StringgetResourceName(S resource)Get the resource name.protected abstract Sload(InputStream in, String source)Load a resource.List<S>loadAllResources()Load all available resources.List<S>loadResources(String resourceName)Load a resource.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface fr.ens.biologie.genomique.eoulsan.util.ResourceLoader
reload
-
-
-
-
Method Detail
-
getResourceAsStream
protected abstract InputStream getResourceAsStream(String resourcePath) throws IOException
Get the input stream related to a resource.- Parameters:
resourcePath- resource path- Returns:
- a resource object
- Throws:
IOException- if an error occurs while creating the input stream
-
load
protected abstract S load(InputStream in, String source) throws IOException, EoulsanException
Load a resource.- Parameters:
in- input streamsource- source of the resource- Returns:
- a resource object
- Throws:
IOException- if an error occurs while loading the resourceEoulsanException- if an error occurs while creating the resource object
-
getResourceName
protected abstract String getResourceName(S resource)
Get the resource name.- Parameters:
resource- the resource- Returns:
- the name of the resource
-
addResource
protected void addResource(String resourceName, String resourcePath)
Add a resource.- Parameters:
resourceName- resource nameresourcePath- resource path
-
loadAllResources
public List<S> loadAllResources()
Description copied from interface:ResourceLoaderLoad all available resources.- Specified by:
loadAllResourcesin interfaceResourceLoader<S>- Returns:
- a list with all the loaded resources
-
loadResources
public List<S> loadResources(String resourceName)
Description copied from interface:ResourceLoaderLoad a resource.- Specified by:
loadResourcesin interfaceResourceLoader<S>- Parameters:
resourceName- name of the resource to load- Returns:
- a list the loaded resources that had the requested name
-
-