Stuart McCulloch | 5ec302d | 2008-12-04 07:58:07 +0000 | [diff] [blame] | 1 | package aQute.lib.osgi; |
| 2 | |
| 3 | import java.io.*; |
| 4 | |
| 5 | public class JarResource implements Resource { |
| 6 | Jar jar; |
| 7 | String extra; |
| 8 | |
| 9 | public JarResource(Jar jar ) { |
| 10 | this.jar = jar; |
| 11 | } |
| 12 | |
| 13 | public String getExtra() { |
| 14 | return extra; |
| 15 | } |
| 16 | |
| 17 | public long lastModified() { |
| 18 | return jar.lastModified(); |
| 19 | } |
| 20 | |
| 21 | |
| 22 | public void write(OutputStream out) throws IOException { |
| 23 | jar.write(out); |
| 24 | } |
| 25 | |
| 26 | public InputStream openInputStream() throws IOException { |
| 27 | ByteArrayOutputStream out = new ByteArrayOutputStream(); |
| 28 | write(out); |
| 29 | out.close(); |
| 30 | ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); |
| 31 | return in; |
| 32 | } |
| 33 | |
| 34 | public void setExtra(String extra) { |
| 35 | this.extra = extra; |
| 36 | } |
| 37 | |
| 38 | public Jar getJar() { |
| 39 | return jar; |
| 40 | } |
| 41 | |
| 42 | } |