org.eclipse.actf.util.resources
Class DefaultResourceLocator

java.lang.Object
  extended by org.eclipse.actf.util.resources.DefaultResourceLocator
All Implemented Interfaces:
IResourceLocator
Direct Known Subclasses:
EclipseResourceLocator, InterJvmResourceLocator

public class DefaultResourceLocator
extends Object
implements IResourceLocator

a default implementation of the IResourceLocator interface for ACTF. Subclasses add special functionality for locating resources (e.g. .properties files) in particular environments.

Author:
Barry Feigenbaum

Field Summary
 
Fields inherited from interface org.eclipse.actf.util.resources.IResourceLocator
ACTF_RESOURCES_PATHS_KEY, DEFAULT_ACTF_RESOURCES_DIR
 
Constructor Summary
DefaultResourceLocator()
           
 
Method Summary
 String getPath(String name)
          find the Path with the given name.
 String[] getPaths(String name)
          find the paths with the given name.
 URL getResource(String name)
          find the resource with the given name.
protected  InputStream getResourceAsBufferedStream(String id, ClassLoader loader)
           
protected  InputStream getResourceAsBufferedStream(String id, String base, String ext, ClassLoader loader)
           
 InputStream getResourceAsStream(String id)
          get the resource with the given id as a stream and using the class loader that loaded this IResourceLocator instance.
 InputStream getResourceAsStream(String id, ClassLoader loader)
          get the resource corresponding to the given id as a stream using the specified class loader.
 InputStream getResourceAsStream(String id, String base, String ext, ClassLoader loader)
          get the resource corresponding to the given id as a stream using the specified class loader.
 URL[] getResources(String name)
          find the resources with the given name.
protected  InputStream makeBufferedStream(InputStream is)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultResourceLocator

public DefaultResourceLocator()
Method Detail

getResourceAsStream

public InputStream getResourceAsStream(String id)
get the resource with the given id as a stream and using the class loader that loaded this IResourceLocator instance.

Specified by:
getResourceAsStream in interface IResourceLocator
Parameters:
id - - id of resource
Returns:
input stream

getResourceAsStream

public InputStream getResourceAsStream(String id,
                                       ClassLoader loader)
get the resource corresponding to the given id as a stream using the specified class loader.

Specified by:
getResourceAsStream in interface IResourceLocator
Parameters:
id - - id of resource
loader - -- class loader to use
Returns:
input stream

getResourceAsStream

public InputStream getResourceAsStream(String id,
                                       String base,
                                       String ext,
                                       ClassLoader loader)
get the resource corresponding to the given id as a stream using the specified class loader. The base path and extention of the file resource are also specified.

Specified by:
getResourceAsStream in interface IResourceLocator
Parameters:
id - - id of resource
base - - base path
ext - -extentio
loader - -- class loader to use
Returns:
input streamn

makeBufferedStream

protected InputStream makeBufferedStream(InputStream is)

getResourceAsBufferedStream

protected InputStream getResourceAsBufferedStream(String id,
                                                  ClassLoader loader)

getResourceAsBufferedStream

protected InputStream getResourceAsBufferedStream(String id,
                                                  String base,
                                                  String ext,
                                                  ClassLoader loader)

getResource

public URL getResource(String name)
Description copied from interface: IResourceLocator
find the resource with the given name. The name is a /-separated path describing the relative path to the resource.

Specified by:
getResource in interface IResourceLocator
Parameters:
name - - name of resource
Returns:
URL of a resource with the given name or null if no resources with the given name could be found
See Also:
ClassLoader.getResource(String)

getResources

public URL[] getResources(String name)
Description copied from interface: IResourceLocator
find the resources with the given name. The name is a /-separated path describing the relative path to the resource.

Specified by:
getResources in interface IResourceLocator
Parameters:
name - - name of resource
Returns:
URL of all resources with the given name or null if no resources with the given name could be found
See Also:
ClassLoader.getResources(String)

getPath

public String getPath(String name)
Description copied from interface: IResourceLocator
find the Path with the given name. The name is a /-separated path describing the relative path to the resource.

Specified by:
getPath in interface IResourceLocator
Parameters:
name - - name of resource
Returns:
String file representation of the URL returned from getResources or null if no resources with the given name could be found
See Also:
ClassLoader.getResource(String)

getPaths

public String[] getPaths(String name)
Description copied from interface: IResourceLocator
find the paths with the given name. The name is a /-separated path describing the relative path to the resource.

Specified by:
getPaths in interface IResourceLocator
Parameters:
name - - name of resource
Returns:
String[] file representation of the URL[] returned from getResources or null if no resources with the given name could be found
See Also:
ClassLoader.getResources(String)