diff options
author | PJ Fanning <fanningpj@apache.org> | 2024-07-01 21:30:07 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2024-07-01 21:30:07 +0000 |
commit | d879a94a156b69e5d0ddc1cf23716ed3905edc69 (patch) | |
tree | 0f365ef3fa4bdbfa1307cb4eb8b902bf950756bb /poi-ooxml/src | |
parent | 527f26aac99d8a15fd8a418ccdbe646ee9f38eea (diff) | |
download | poi-d879a94a156b69e5d0ddc1cf23716ed3905edc69.tar.gz poi-d879a94a156b69e5d0ddc1cf23716ed3905edc69.zip |
reformat ZipFileZipEntrySource.java
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918799 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml/src')
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java | 111 |
1 files changed, 56 insertions, 55 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java index 0dafb13443..406e62f1ed 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java @@ -26,61 +26,62 @@ import org.apache.commons.compress.archivers.zip.ZipFile; /** * 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; - } - } - - return null; - } + 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; + } + } + + return null; + } } |