commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r749555 - /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java
Date Tue, 03 Mar 2009 07:51:43 GMT
Author: bodewig
Date: Tue Mar  3 07:51:43 2009
New Revision: 749555

URL: http://svn.apache.org/viewvc?rev=749555&view=rev
Log:
coding style

Modified:
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java?rev=749555&r1=749554&r2=749555&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java
Tue Mar  3 07:51:43 2009
@@ -19,133 +19,114 @@
 package org.apache.commons.compress.archivers.zip;
 
 /**
- * Simple placeholder for all those extra fields we don't want to deal with. <p>
+ * Simple placeholder for all those extra fields we don't want to deal
+ * with.
+ *
+ * <p>Assumes local file data and central directory entries are
+ * identical - unless told the opposite.</p>
  *
- * Assumes local file data and central directory entries are identical - unless
- * told the opposite.</p>
  */
-public class UnrecognizedExtraField
-    implements ZipExtraField
-{
-    /**
-     * Extra field data in central directory - without Header-ID or length
-     * specifier.
-     */
-    private byte[] m_centralData;
+public class UnrecognizedExtraField implements ZipExtraField {
 
     /**
      * The Header-ID.
      */
-    private ZipShort m_headerID;
+    private ZipShort headerId;
 
     /**
-     * Extra field data in local file data - without Header-ID or length
-     * specifier.
+     * Set the header id.
+     * @param headerId the header id to use
      */
-    private byte[] m_localData;
+    public void setHeaderId(ZipShort headerId) {
+        this.headerId = headerId;
+    }
 
     /**
-     * Set the central directory data
-     *
-     * @param centralData the central directory data
+     * Get the header id.
+     * @return the header id
      */
-    public void setCentralDirectoryData( final byte[] centralData )
-    {
-        m_centralData = copy(centralData);
+    public ZipShort getHeaderId() {
+        return headerId;
     }
 
-       /**
-     * Set the header ID.
-     *
-     * @param headerID the header ID
+    /**
+     * Extra field data in local file data - without
+     * Header-ID or length specifier.
      */
-    public void setHeaderId( final ZipShort headerID )
-    {
-        m_headerID = headerID;
-    }
+    private byte[] localData;
 
     /**
-     * Set the local file data.
-     *
-     * @param localData the local file data
+     * Set the extra field data in the local file data -
+     * without Header-ID or length specifier.
+     * @param data the field data to use
      */
-    public void setLocalFileDataData( final byte[] localData )
-    {
-        m_localData = copy(localData);
+    public void setLocalFileDataData(byte[] data) {
+        localData = copy(data);
     }
 
     /**
-     * Get the central directory data.
-     *
-     * @return the central directory data.
+     * Get the length of the local data.
+     * @return the length of the local data
      */
-    public byte[] getCentralDirectoryData()
-    {
-        if( m_centralData != null )
-        {
-            return copy(m_centralData);
-        }
-        return getLocalFileDataData();
+    public ZipShort getLocalFileDataLength() {
+        return new ZipShort(localData.length);
     }
 
     /**
-     * Get the length of the central directory in bytes.
-     *
-     * @return the length of the central directory in bytes.
-     */
-    public ZipShort getCentralDirectoryLength()
-    {
-        if( m_centralData != null )
-        {
-            return new ZipShort( m_centralData.length );
-        }
-        return getLocalFileDataLength();
+     * Get the local data.
+     * @return the local data
+     */
+    public byte[] getLocalFileDataData() {
+        return copy(localData);
     }
 
     /**
-     * Get the HeaderID.
-     *
-     * @return the HeaderID
+     * Extra field data in central directory - without
+     * Header-ID or length specifier.
      */
-    public ZipShort getHeaderId()
-    {
-        return m_headerID;
-    }
+    private byte[] centralData;
 
     /**
-     * Get the local file data.
-     *
-     * @return the local file data
+     * Set the extra field data in central directory.
+     * @param data the data to use
      */
-    public byte[] getLocalFileDataData()
-    {
-        return copy(m_localData);
+    public void setCentralDirectoryData(byte[] data) {
+        centralData = copy(data);
     }
 
     /**
-     * Get the length of local file data in bytes.
-     *
-     * @return the length of local file data in bytes
+     * Get the central data length.
+     * If there is no central data, get the local file data length.
+     * @return the central data length
      */
-    public ZipShort getLocalFileDataLength()
-    {
-        return new ZipShort( m_localData.length );
+    public ZipShort getCentralDirectoryLength() {
+        if (centralData != null) {
+            return new ZipShort(centralData.length);
+        }
+        return getLocalFileDataLength();
     }
 
     /**
-     * Parse LocalFiledata out of supplied buffer.
-     *
-     * @param buffer the buffer to use
-     * @param offset the offset into buffer
-     * @param length then length of data
+     * Get the central data.
+     * @return the central data if present, else return the local file data
      */
-    public void parseFromLocalFileData( final byte[] buffer,
-                                        final int offset,
-                                        final int length )
-    {
-        final byte[] fileData = new byte[ length ];
-        System.arraycopy( buffer, offset, fileData, 0, length );
-        setLocalFileDataData( fileData );
+    public byte[] getCentralDirectoryData() {
+        if (centralData != null) {
+            return copy(centralData);
+        }
+        return getLocalFileDataData();
+    }
+
+    /**
+     * @param data the array of bytes.
+     * @param offset the source location in the data array.
+     * @param length the number of bytes to use in the data array.
+     * @see ZipExtraField#parseFromLocalFileData(byte[], int, int)
+     */
+    public void parseFromLocalFileData(byte[] data, int offset, int length) {
+        byte[] tmp = new byte[length];
+        System.arraycopy(data, offset, tmp, 0, length);
+        setLocalFileDataData(tmp);
     }
 
     private static byte[] copy(byte[] from) {



Mime
View raw message