1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.xar; |
21 |
|
|
22 |
|
import java.io.Closeable; |
23 |
|
import java.io.File; |
24 |
|
import java.io.IOException; |
25 |
|
import java.io.InputStream; |
26 |
|
import java.util.Collection; |
27 |
|
|
28 |
|
import org.apache.commons.compress.archivers.zip.ZipFile; |
29 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
30 |
|
|
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
|
|
| 48.3% |
Uncovered Elements: 15 (29) |
Complexity: 12 |
Complexity Density: 0.86 |
|
35 |
|
public class XarFile implements Closeable |
36 |
|
{ |
37 |
|
private File file; |
38 |
|
|
39 |
|
private ZipFile zipFile; |
40 |
|
|
41 |
|
private XarPackage xarPackage; |
42 |
|
|
43 |
|
|
44 |
|
@param |
45 |
|
@throws |
46 |
|
@throws |
47 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
48 |
0 |
public XarFile(File file) throws XarException, IOException... |
49 |
|
{ |
50 |
0 |
this(file, (XarPackage) null); |
51 |
|
} |
52 |
|
|
53 |
|
|
54 |
|
@param |
55 |
|
@param |
56 |
|
@throws |
57 |
|
@throws |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
59 |
0 |
public XarFile(File file, Collection<XarEntry> pages) throws XarException, IOException... |
60 |
|
{ |
61 |
0 |
this(file, pages != null ? new XarPackage(pages) : null); |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
@param |
66 |
|
@param |
67 |
|
@throws |
68 |
|
@throws |
69 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
70 |
24 |
public XarFile(File file, XarPackage xarPackage) throws XarException, IOException... |
71 |
|
{ |
72 |
24 |
this.file = file; |
73 |
24 |
this.zipFile = new ZipFile(file); |
74 |
24 |
this.xarPackage = xarPackage != null ? xarPackage : new XarPackage(this.zipFile); |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
@return |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
0 |
public File getFile()... |
81 |
|
{ |
82 |
0 |
return this.file; |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
119 |
@Override... |
86 |
|
public void close() throws IOException |
87 |
|
{ |
88 |
119 |
this.zipFile.close(); |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
|
@param |
93 |
|
@return |
94 |
|
@throws |
95 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
96 |
134 |
public InputStream getInputStream(LocalDocumentReference reference) throws IOException... |
97 |
|
{ |
98 |
134 |
XarEntry entry = this.xarPackage.getEntry(reference); |
99 |
134 |
if (entry == null) { |
100 |
0 |
throw new IOException("Failed to find entry for referenc [" + reference + "]"); |
101 |
|
} |
102 |
|
|
103 |
134 |
return this.zipFile.getInputStream(this.zipFile.getEntry(entry.getEntryName())); |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
@return |
108 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
109 |
0 |
public Collection<XarEntry> getEntries()... |
110 |
|
{ |
111 |
0 |
return this.xarPackage.getEntries(); |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
|
@param |
116 |
|
@return |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
118 |
134 |
public XarEntry getEntry(LocalDocumentReference reference)... |
119 |
|
{ |
120 |
134 |
return this.xarPackage.getEntry(reference); |
121 |
|
} |
122 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
123 |
0 |
@Override... |
124 |
|
public String toString() |
125 |
|
{ |
126 |
0 |
return this.file.toString(); |
127 |
|
} |
128 |
|
} |