private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccessData data, JarEntryFilter filter, JarFileType type) throws IOException { super(rootFile.getFile()); this.rootFile = rootFile; this.pathFromRoot = pathFromRoot; CentralDirectoryParser parser = new CentralDirectoryParser(); this.entries = parser.addVisitor(new JarFileEntries(this, filter)); parser.addVisitor(centralDirectoryVisitor()); this.data = parser.parse(data, filter == null); this.type = type; }
@Test public void close() throws Exception { RandomAccessDataFile randomAccessDataFile = spy( new RandomAccessDataFile(this.rootJarFile, 1)); JarFile jarFile = new JarFile(randomAccessDataFile); jarFile.close(); verify(randomAccessDataFile).close(); }
/** * Private constructor used to create a new {@link JarFile} either directly or from a * nested entry. * @param rootFile the root jar file * @param pathFromRoot the name of this file * @param data the underlying data * @throws IOException if the file cannot be read */ private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccessData data) throws IOException { super(rootFile.getFile()); CentralDirectoryEndRecord endRecord = new CentralDirectoryEndRecord(data); this.rootFile = rootFile; this.pathFromRoot = pathFromRoot; this.data = getArchiveData(endRecord, data); this.entries = loadJarEntries(endRecord); }
private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccessData data, List<JarEntryData> entries, JarEntryFilter... filters) throws IOException { super(rootFile.getFile()); this.rootFile = rootFile; this.pathFromRoot = pathFromRoot; this.data = data; this.entries = filterEntries(entries, filters); }
protected final RandomAccessDataFile getRootJarFile() { return this.rootFile; }
@Before public void setup() throws Exception { this.jarFile = this.temporaryFolder.newFile(); TestJarCreator.createTestJar(this.jarFile); this.jarData = new RandomAccessDataFile(this.jarFile); }
/** * Create a new {@link JarFile} backed by the specified file. * @param file the root jar file * @throws IOException if the file cannot be read */ public JarFile(File file) throws IOException { this(new RandomAccessDataFile(file)); }
/** * Create a new {@link JarFile} backed by the specified file. * @param file the root jar file * @throws IOException if the file cannot be read */ JarFile(RandomAccessDataFile file) throws IOException { this(file, "", file, JarFileType.DIRECT); }
/** * Private constructor used to create a new {@link JarFile} either directly or from a * nested entry. * @param rootFile the root jar file * @param pathFromRoot the name of this file * @param data the underlying data * @param type the type of the jar file * @throws IOException if the file cannot be read */ private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccessData data, JarFileType type) throws IOException { this(rootFile, pathFromRoot, data, null, type); }
/** * Create a new {@link JarFile} backed by the specified file. * @param file the root jar file * @throws IOException if the file cannot be read */ JarFile(RandomAccessDataFile file) throws IOException { this(file, "", file); }