Clover Coverage Report - Liquibase Core 2.0.3-SNAPSHOT
Coverage timestamp: Sat Aug 6 2011 11:33:15 EDT
../../../img/srcFileCovDistChart5.png 35% of files have more coverage
15   56   7   3
4   43   0.47   5
5     1.4  
1    
 
  CommandLineResourceAccessor       Line # 19 15 0% 7 13 45.8% 0.45833334
 
  (3)
 
1    package liquibase.integration.commandline;
2   
3    import liquibase.resource.ResourceAccessor;
4    import liquibase.util.StringUtils;
5   
6    import java.io.IOException;
7    import java.io.InputStream;
8    import java.net.URL;
9    import java.net.URLClassLoader;
10    import java.util.ArrayList;
11    import java.util.Enumeration;
12    import java.util.List;
13   
14    /**
15    * Implementation of liquibase.FileOpener for the command line app.
16    *
17    * @see liquibase.resource.ResourceAccessor
18    */
 
19    public class CommandLineResourceAccessor implements ResourceAccessor {
20    private ClassLoader loader;
21   
 
22  3 toggle public CommandLineResourceAccessor(ClassLoader loader) {
23  3 this.loader = loader;
24    }
25   
 
26  2 toggle public InputStream getResourceAsStream(String file) throws IOException {
27  2 URL resource = loader.getResource(file);
28  2 if (resource == null) {
29  1 throw new IOException(file + " could not be found");
30    }
31  1 return resource.openStream();
32    }
33   
 
34  1 toggle public Enumeration<URL> getResources(String packageName) throws IOException {
35  1 return loader.getResources(packageName);
36    }
37   
 
38  0 toggle public ClassLoader toClassLoader() {
39  0 return loader;
40    }
41   
 
42  0 toggle @Override
43    public String toString() {
44  0 String description;
45  0 if (loader instanceof URLClassLoader) {
46  0 List<String> urls = new ArrayList<String>();
47  0 for (URL url : ((URLClassLoader) loader).getURLs()) {
48  0 urls.add(url.toExternalForm());
49    }
50  0 description = StringUtils.join(urls, ",");
51    } else {
52  0 description = loader.getClass().getName();
53    }
54  0 return getClass().getName() + "(" + description + ")";
55    }
56    }