1
2
3
4 package net.sourceforge.pmd.util.datasource;
5
6 import java.io.IOException;
7 import java.io.InputStream;
8 import java.util.zip.ZipEntry;
9 import java.util.zip.ZipFile;
10
11
12
13
14
15
16 public class ZipDataSource implements DataSource {
17 private ZipFile zipFile;
18 private ZipEntry zipEntry;
19
20
21
22
23
24 public ZipDataSource(ZipFile zipFile, ZipEntry zipEntry) {
25 this.zipFile = zipFile;
26 this.zipEntry = zipEntry;
27 }
28
29 public InputStream getInputStream() throws IOException {
30 return zipFile.getInputStream(zipEntry);
31 }
32
33 public String getNiceFileName(boolean shortNames, String inputFileName) {
34
35 return zipFile.getName() + ":" + zipEntry.getName();
36 }
37 }