commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r747850 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
Date Wed, 25 Feb 2009 16:29:01 GMT
Author: bodewig
Date: Wed Feb 25 16:29:00 2009
New Revision: 747850

URL: http://svn.apache.org/viewvc?rev=747850&view=rev
Log:
provide direct access to extra fields by id

Modified:
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
    commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java?rev=747850&r1=747849&r2=747850&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
Wed Feb 25 16:29:00 2009
@@ -265,6 +265,18 @@
     }
 
     /**
+     * Looks up an extra field by its header id.
+     *
+     * @return null if no such field exists.
+     */
+    public ZipExtraField getExtraField(ZipShort type) {
+        if (extraFields != null) {
+            return (ZipExtraField) extraFields.get(type);
+        }
+        return null;
+    }
+
+    /**
      * Throws an Exception if extra data cannot be parsed into extra fields.
      * @param extra an array of bytes to be parsed into extra fields
      * @throws RuntimeException if the bytes cannot be parsed

Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java?rev=747850&r1=747849&r2=747850&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
(original)
+++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
Wed Feb 25 16:29:00 2009
@@ -205,14 +205,8 @@
     }
 
     private static UnicodePathExtraField findUniCodePath(ZipArchiveEntry ze) {
-
-        ZipExtraField[] efs = ze.getExtraFields();
-        for (int i = 0; i < efs.length; ++i) {
-            if (efs[i].getHeaderId().equals(UnicodePathExtraField.UPATH_ID)) {
-                return (UnicodePathExtraField) efs[i];
-            }
-        }
-        return null;
+        return (UnicodePathExtraField)
+            ze.getExtraField(UnicodePathExtraField.UPATH_ID);
     }
 
     private static void assertUnicodeName(ZipArchiveEntry ze,



Mime
View raw message