/** * Convenience method that returns the parent {@link AbstractArchiveFile} that contains this file. If this file * is an {@link AbstractArchiveFile} or an ancestor of {@link AbstractArchiveFile}, <code>this</code> is returned. * If this file is neither contained by an archive nor is an archive, <code>null</code> is returned. * * <p> * <b>Important note:</b> the returned {@link AbstractArchiveFile}, if any, may not necessarily be an * archive, as specified by {@link #isArchive()}. This is the case for files that were resolved as * {@link AbstractArchiveFile} instances based on their path, but that do not yet exist or were created as * directories. On the contrary, an existing archive will necessarily return a non-null value. * </p> * * @return the parent {@link AbstractArchiveFile} that contains this file */ public final AbstractArchiveFile getParentArchive() { if(hasAncestor(AbstractArchiveFile.class)) return getAncestor(AbstractArchiveFile.class); else if(hasAncestor(AbstractArchiveEntryFile.class)) return getAncestor(AbstractArchiveEntryFile.class).getArchiveFile(); return null; }