Author: fanningpj Date: Mon Jul 1 21:30:07 2024 New Revision: 1918799 URL: http://svn.apache.org/viewvc?rev=1918799&view=rev Log: reformat ZipFileZipEntrySource.java
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java?rev=1918799&r1=1918798&r2=1918799&view=diff ============================================================================== --- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java (original) +++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java Mon Jul 1 21:30:07 2024 @@ -26,61 +26,62 @@ import org.apache.commons.compress.archi /** * A ZipEntrySource wrapper around a ZipFile. * Should be as low in terms of memory as a - * normal ZipFile implementation is. + * normal ZipFile implementation is. */ public class ZipFileZipEntrySource implements ZipEntrySource { - private ZipFile zipArchive; - public ZipFileZipEntrySource(ZipFile zipFile) { - this.zipArchive = zipFile; - } - - @Override - public void close() throws IOException { - if(zipArchive != null) { - zipArchive.close(); - } - zipArchive = null; - } - - @Override - public boolean isClosed() { - return (zipArchive == null); - } - - @Override - public Enumeration<? extends ZipArchiveEntry> getEntries() { - if (zipArchive == null) - throw new IllegalStateException("Zip File is closed"); - - return zipArchive.getEntries(); - } - - @Override - public InputStream getInputStream(ZipArchiveEntry entry) throws IOException { - if (zipArchive == null) - throw new IllegalStateException("Zip File is closed"); - - return zipArchive.getInputStream(entry); - } - - @Override - public ZipArchiveEntry getEntry(final String path) { - String normalizedPath = path.replace('\\', '/'); - - final ZipArchiveEntry entry = zipArchive.getEntry(normalizedPath); - if (entry != null) { - return entry; - } - - // the opc spec allows case-insensitive filename matching (see #49609) - final Enumeration<ZipArchiveEntry> zipArchiveEntryEnumeration = zipArchive.getEntries(); - while (zipArchiveEntryEnumeration.hasMoreElements()) { - ZipArchiveEntry ze = zipArchiveEntryEnumeration.nextElement(); - if (normalizedPath.equalsIgnoreCase(ze.getName().replace('\\','/'))) { - return ze; - } - } + private ZipFile zipArchive; - return null; - } + public ZipFileZipEntrySource(ZipFile zipFile) { + this.zipArchive = zipFile; + } + + @Override + public void close() throws IOException { + if (zipArchive != null) { + zipArchive.close(); + } + zipArchive = null; + } + + @Override + public boolean isClosed() { + return (zipArchive == null); + } + + @Override + public Enumeration<? extends ZipArchiveEntry> getEntries() { + if (zipArchive == null) + throw new IllegalStateException("Zip File is closed"); + + return zipArchive.getEntries(); + } + + @Override + public InputStream getInputStream(ZipArchiveEntry entry) throws IOException { + if (zipArchive == null) + throw new IllegalStateException("Zip File is closed"); + + return zipArchive.getInputStream(entry); + } + + @Override + public ZipArchiveEntry getEntry(final String path) { + String normalizedPath = path.replace('\\', '/'); + + final ZipArchiveEntry entry = zipArchive.getEntry(normalizedPath); + if (entry != null) { + return entry; + } + + // the opc spec allows case-insensitive filename matching (see #49609) + final Enumeration<ZipArchiveEntry> zipArchiveEntryEnumeration = zipArchive.getEntries(); + while (zipArchiveEntryEnumeration.hasMoreElements()) { + ZipArchiveEntry ze = zipArchiveEntryEnumeration.nextElement(); + if (normalizedPath.equalsIgnoreCase(ze.getName().replace('\\', '/'))) { + return ze; + } + } + + return null; + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org