Package com.ibm.wala.util.io
Class FileProvider
- java.lang.Object
-
- com.ibm.wala.util.io.FileProvider
-
public class FileProvider extends Object
This class provides files that are packaged with this plug-in
-
-
Constructor Summary
Constructors Constructor Description FileProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
filePathFromURL(URL url)
Properly creates the String file name of aURL
.File
getFile(String fileName)
File
getFile(String fileName, ClassLoader loader)
File
getFileFromClassLoader(String fileName, ClassLoader loader)
InputStream
getInputStreamFromClassLoader(String fileName, ClassLoader loader)
First tries to read fileName from the ClassLoader loader.Module
getJarFileFromClassLoader(String fileName, ClassLoader loader)
Module
getJarFileModule(String fileName)
Module
getJarFileModule(String fileName, ClassLoader loader)
URL
getResource(String fileName)
URL
getResource(String fileName, ClassLoader loader)
-
-
-
Method Detail
-
getJarFileModule
public Module getJarFileModule(String fileName) throws IOException
- Parameters:
fileName
-- Returns:
- the jar file packaged with this plug-in of the given name, or null if not found.
- Throws:
IOException
-
getJarFileModule
public Module getJarFileModule(String fileName, ClassLoader loader) throws IOException
- Throws:
IOException
-
getResource
public URL getResource(String fileName) throws IOException
- Throws:
IOException
-
getResource
public URL getResource(String fileName, ClassLoader loader) throws IOException
- Throws:
IOException
-
getFile
public File getFile(String fileName) throws IOException
- Throws:
IOException
-
getFile
public File getFile(String fileName, ClassLoader loader) throws IOException
- Throws:
IOException
-
getFileFromClassLoader
public File getFileFromClassLoader(String fileName, ClassLoader loader) throws FileNotFoundException
- Throws:
FileNotFoundException
-
getInputStreamFromClassLoader
public InputStream getInputStreamFromClassLoader(String fileName, ClassLoader loader) throws FileNotFoundException
First tries to read fileName from the ClassLoader loader. If unsuccessful, attempts to read file from the file system. If that fails, throws aFileNotFoundException
- Throws:
FileNotFoundException
-
getJarFileFromClassLoader
public Module getJarFileFromClassLoader(String fileName, ClassLoader loader) throws IOException
- Returns:
- the jar file packaged with this plug-in of the given name, or null if not found: wrapped as a JarFileModule or a NestedJarFileModule
- Throws:
IOException
-
filePathFromURL
public String filePathFromURL(URL url)
Properly creates the String file name of aURL
. This works around a bug in the Sun implementation ofURL.getFile()
, which doesn't properly handle file paths with spaces (see bug report). For now, fails with an assertion if the url is malformed.- Parameters:
url
-- Returns:
- the path name for the url
- Throws:
IllegalArgumentException
- if url is null
-
-