43
43
* Extended variant of {@link java.util.jar.JarFile} that behaves in the same way but
44
44
* offers the following additional functionality.
45
45
* <ul>
46
- * <li>Jar entries can be {@link JarEntryFilter filtered} during construction and new
47
- * filtered files can be {@link #getFilteredJarFile(JarEntryFilter...) created} from
48
- * existing files.</li>
49
- * <li>A nested {@link JarFile} can be
50
- * {@link #getNestedJarFile(ZipEntry, JarEntryFilter...) obtained} based on any directory
51
- * entry.</li>
52
- * <li>A nested {@link JarFile} can be
53
- * {@link #getNestedJarFile(ZipEntry, JarEntryFilter...) obtained} for embedded JAR files
54
- * (as long as their entry is not compressed).</li>
46
+ * <li>New filtered files can be {@link #getFilteredJarFile(JarEntryFilter...) created}
47
+ * from existing files.</li>
48
+ * <li>A nested {@link JarFile} can be {@link #getNestedJarFile(ZipEntry) obtained} based
49
+ * on any directory entry.</li>
50
+ * <li>A nested {@link JarFile} can be {@link #getNestedJarFile(ZipEntry) obtained} for
51
+ * embedded JAR files (as long as their entry is not compressed).</li>
55
52
* <li>Entry data can be accessed as {@link RandomAccessData}.</li>
56
53
* </ul>
57
54
*
@@ -90,21 +87,19 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
90
87
/**
91
88
* Create a new {@link JarFile} backed by the specified file.
92
89
* @param file the root jar file
93
- * @param filters an optional set of jar entry filters
94
90
* @throws IOException
95
91
*/
96
- public JarFile (File file , JarEntryFilter ... filters ) throws IOException {
97
- this (new RandomAccessDataFile (file ), filters );
92
+ public JarFile (File file ) throws IOException {
93
+ this (new RandomAccessDataFile (file ));
98
94
}
99
95
100
96
/**
101
97
* Create a new {@link JarFile} backed by the specified file.
102
98
* @param file the root jar file
103
- * @param filters an optional set of jar entry filters
104
99
* @throws IOException
105
100
*/
106
- JarFile (RandomAccessDataFile file , JarEntryFilter ... filters ) throws IOException {
107
- this (file , file .getFile ().getAbsolutePath (), file , filters );
101
+ JarFile (RandomAccessDataFile file ) throws IOException {
102
+ this (file , file .getFile ().getAbsolutePath (), file );
108
103
}
109
104
110
105
/**
@@ -297,41 +292,37 @@ public synchronized InputStream getInputStream(ZipEntry ze) throws IOException {
297
292
/**
298
293
* Return a nested {@link JarFile} loaded from the specified entry.
299
294
* @param ze the zip entry
300
- * @param filters an optional set of jar entry filters to be applied
301
295
* @return a {@link JarFile} for the entry
302
296
* @throws IOException
303
297
*/
304
- public synchronized JarFile getNestedJarFile (final ZipEntry ze ,
305
- JarEntryFilter ... filters ) throws IOException {
298
+ public synchronized JarFile getNestedJarFile (final ZipEntry ze ) throws IOException {
306
299
return getNestedJarFile (getContainedEntry (ze ).getSource ());
307
300
}
308
301
309
302
/**
310
303
* Return a nested {@link JarFile} loaded from the specified entry.
311
304
* @param sourceEntry the zip entry
312
- * @param filters an optional set of jar entry filters to be applied
313
305
* @return a {@link JarFile} for the entry
314
306
* @throws IOException
315
307
*/
316
- public synchronized JarFile getNestedJarFile (final JarEntryData sourceEntry ,
317
- JarEntryFilter ... filters ) throws IOException {
308
+ public synchronized JarFile getNestedJarFile (final JarEntryData sourceEntry )
309
+ throws IOException {
318
310
try {
319
311
if (sourceEntry .isDirectory ()) {
320
- return getNestedJarFileFromDirectoryEntry (sourceEntry , filters );
312
+ return getNestedJarFileFromDirectoryEntry (sourceEntry );
321
313
}
322
- return getNestedJarFileFromFileEntry (sourceEntry , filters );
314
+ return getNestedJarFileFromFileEntry (sourceEntry );
323
315
}
324
316
catch (IOException ex ) {
325
317
throw new IOException ("Unable to open nested jar file '"
326
318
+ sourceEntry .getName () + "'" , ex );
327
319
}
328
320
}
329
321
330
- private JarFile getNestedJarFileFromDirectoryEntry (JarEntryData sourceEntry ,
331
- JarEntryFilter ... filters ) throws IOException {
322
+ private JarFile getNestedJarFileFromDirectoryEntry (JarEntryData sourceEntry )
323
+ throws IOException {
332
324
final AsciiBytes sourceName = sourceEntry .getName ();
333
- JarEntryFilter [] filtersToUse = new JarEntryFilter [filters .length + 1 ];
334
- System .arraycopy (filters , 0 , filtersToUse , 1 , filters .length );
325
+ JarEntryFilter [] filtersToUse = new JarEntryFilter [1 ];
335
326
filtersToUse [0 ] = new JarEntryFilter () {
336
327
@ Override
337
328
public AsciiBytes apply (AsciiBytes name , JarEntryData entryData ) {
@@ -346,14 +337,14 @@ public AsciiBytes apply(AsciiBytes name, JarEntryData entryData) {
346
337
filtersToUse );
347
338
}
348
339
349
- private JarFile getNestedJarFileFromFileEntry (JarEntryData sourceEntry ,
350
- JarEntryFilter ... filters ) throws IOException {
340
+ private JarFile getNestedJarFileFromFileEntry (JarEntryData sourceEntry )
341
+ throws IOException {
351
342
if (sourceEntry .getMethod () != ZipEntry .STORED ) {
352
343
throw new IllegalStateException ("Unable to open nested compressed entry "
353
344
+ sourceEntry .getName ());
354
345
}
355
346
return new JarFile (this .rootFile , getName () + "!/" + sourceEntry .getName (),
356
- sourceEntry .getData (), filters );
347
+ sourceEntry .getData ());
357
348
}
358
349
359
350
/**
0 commit comments