org.codehaus.cargo.container.internal.util
Class ResourceUtils

java.lang.Object
  extended by org.codehaus.cargo.util.log.LoggedObject
      extended by org.codehaus.cargo.container.internal.util.ResourceUtils
All Implemented Interfaces:
Loggable

public final class ResourceUtils
extends LoggedObject

Utility class that provides a couple of methods for extracting files stored as resource in a JAR.

Version:
$Id: ResourceUtils.java 1705 2008-09-02 13:14:55Z adriana $

Constructor Summary
ResourceUtils()
           
 
Method Summary
 void copyResource(String resourceName, File destFile)
          Copies a container resource from the JAR into the specified file.
 void copyResource(String resourceName, File destFile, org.apache.tools.ant.types.FilterChain filterChain)
          Copies a container resource from the JAR into the specified file, thereby applying the specified filters.
 void copyResource(String resourceName, String destFile, FileHandler handler)
          Copies a container resource from the JAR into the specified file using the specified file handler.
 void copyResource(String resourceName, String destFile, FileHandler handler, org.apache.tools.ant.types.FilterChain filterChain)
          Copies a container resource from the JAR into the specified file, using the specified file handler thereby applying the specified filters.
 File getResourceLocation(String resourceName)
          Search for the given resource and return the directory or archive that contains it.
 
Methods inherited from class org.codehaus.cargo.util.log.LoggedObject
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceUtils

public ResourceUtils()
Method Detail

copyResource

public void copyResource(String resourceName,
                         File destFile)
                  throws IOException
Copies a container resource from the JAR into the specified file.

Parameters:
resourceName - The name of the resource
destFile - The file to which the contents of the resource should be copied
Throws:
IOException - If an I/O error occurs while copying the resource

copyResource

public void copyResource(String resourceName,
                         String destFile,
                         FileHandler handler)
                  throws IOException
Copies a container resource from the JAR into the specified file using the specified file handler.

Parameters:
resourceName - The name of the resource
destFile - The file to which the contents of the resource should be copied
handler - The file handler to use
Throws:
IOException - If an I/O error occurs while copying the resource

copyResource

public void copyResource(String resourceName,
                         File destFile,
                         org.apache.tools.ant.types.FilterChain filterChain)
                  throws IOException
Copies a container resource from the JAR into the specified file, thereby applying the specified filters.

Parameters:
resourceName - The name of the resource, relative to the org.apache.cactus.integration.ant.container package
destFile - The file to which the contents of the resource should be copied
filterChain - The ordered list of filter readers that should be applied while copying
Throws:
IOException - If an I/O error occurs while copying the resource

copyResource

public void copyResource(String resourceName,
                         String destFile,
                         FileHandler handler,
                         org.apache.tools.ant.types.FilterChain filterChain)
                  throws IOException
Copies a container resource from the JAR into the specified file, using the specified file handler thereby applying the specified filters.

Parameters:
resourceName - The name of the resource, relative to the org.apache.cactus.integration.ant.container package
destFile - The file to which the contents of the resource should be copied
handler - The file handler to be used for file copy
filterChain - The ordered list of filter readers that should be applied while copying
Throws:
IOException - If an I/O error occurs while copying the resource

getResourceLocation

public File getResourceLocation(String resourceName)
Search for the given resource and return the directory or archive that contains it.

Doesn't work for archives in JDK 1.1 as the URL returned by getResource doesn't contain the name of the archive.

Parameters:
resourceName - The name of the resource
Returns:
The directory or archive containing the specified resource


Copyright © 2004-2012 Codehaus. All Rights Reserved.