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 |
|
|
16 |
|
|
17 |
|
@see |
18 |
|
|
|
|
| 45.8% |
Uncovered Elements: 13 (24) |
Complexity: 7 |
Complexity Density: 0.47 |
|
19 |
|
public class CommandLineResourceAccessor implements ResourceAccessor { |
20 |
|
private ClassLoader loader; |
21 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
22 |
3
|
public CommandLineResourceAccessor(ClassLoader loader) {... |
23 |
3
|
this.loader = loader; |
24 |
|
} |
25 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
26 |
2
|
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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
34 |
1
|
public Enumeration<URL> getResources(String packageName) throws IOException {... |
35 |
1
|
return loader.getResources(packageName); |
36 |
|
} |
37 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
38 |
0
|
public ClassLoader toClassLoader() {... |
39 |
0
|
return loader; |
40 |
|
} |
41 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
42 |
0
|
@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 |
|
} |