|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ClassResourceStreamFactory.java | 100% | 77.8% | 66.7% | 76.5% |
|
1 |
/*
|
|
2 |
* Joey and its relative products are published under the terms
|
|
3 |
* of the Apache Software License.
|
|
4 |
*/
|
|
5 |
package org.asyrinx.brownie.core.io.sf;
|
|
6 |
|
|
7 |
import java.io.IOException;
|
|
8 |
import java.io.InputStream;
|
|
9 |
import java.io.OutputStream;
|
|
10 |
|
|
11 |
/**
|
|
12 |
* @author Akima
|
|
13 |
*/
|
|
14 |
public class ClassResourceStreamFactory extends AbstractFileStreamFactory { |
|
15 |
|
|
16 |
/**
|
|
17 |
* Constructor for ClassResourceStreamFactory.
|
|
18 |
*/
|
|
19 | 4 |
public ClassResourceStreamFactory() {
|
20 | 4 |
this(null); |
21 |
} |
|
22 |
|
|
23 |
/**
|
|
24 |
* Constructor for ClassResourceStreamFactory.
|
|
25 |
*/
|
|
26 | 5 |
public ClassResourceStreamFactory(ClassLoader classLoader) {
|
27 | 5 |
super();
|
28 | 5 |
if (classLoader == null) |
29 | 4 |
classLoader = this.getClass().getClassLoader();
|
30 | 5 |
this.classLoader = classLoader;
|
31 |
} |
|
32 |
|
|
33 |
/**
|
|
34 |
* @see org.asyrinx.brownie.core.io.sf.FileStreamFactory#toFile(java.lang.String)
|
|
35 |
*/
|
|
36 | 0 |
public String toFilePath(String fileName) {
|
37 | 0 |
return fileName;
|
38 |
} |
|
39 |
|
|
40 |
private final ClassLoader classLoader;
|
|
41 |
|
|
42 |
/**
|
|
43 |
*/
|
|
44 | 9 |
public InputStream newInput(String fileName) throws IOException { |
45 | 9 |
return newInputImpl(fileName);
|
46 |
} |
|
47 |
|
|
48 |
/**
|
|
49 |
*/
|
|
50 | 9 |
protected final InputStream newInputImpl(String fileName) {
|
51 | 9 |
return this.classLoader.getResourceAsStream(fileName); |
52 |
} |
|
53 |
|
|
54 |
/**
|
|
55 |
*/
|
|
56 | 0 |
public OutputStream newOutput(String fileName) throws IOException { |
57 | 0 |
throw new UnsupportedOperationException(); |
58 |
} |
|
59 |
|
|
60 |
} |
|