You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2001/12/22 13:47:28 UTC

cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip AsiExtraField.java UnrecognizedExtraField.java ZipEntry.java ZipExtraField.java ZipLong.java ZipOutputStream.java ZipShort.java

donaldp     01/12/22 04:47:28

  Modified:    proposal/myrmidon/src/main/org/apache/tools/zip
                        AsiExtraField.java UnrecognizedExtraField.java
                        ZipEntry.java ZipExtraField.java ZipLong.java
                        ZipOutputStream.java ZipShort.java
  Log:
  restyled
  
  Revision  Changes    Path
  1.2       +19 -16    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/AsiExtraField.java
  
  Index: AsiExtraField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/AsiExtraField.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AsiExtraField.java	2001/12/15 12:06:33	1.1
  +++ AsiExtraField.java	2001/12/22 12:47:28	1.2
  @@ -6,6 +6,7 @@
    * the LICENSE file.
    */
   package org.apache.tools.zip;
  +
   import java.util.zip.CRC32;
   import java.util.zip.ZipException;
   
  @@ -32,7 +33,7 @@
    * device numbers are currently not supported.</p>
    *
    * @author <a href="stefan.bodewig@epost.de">Stefan Bodewig</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable
   {
  @@ -79,7 +80,9 @@
        */
       private CRC32 crc = new CRC32();
   
  -    public AsiExtraField() { }
  +    public AsiExtraField()
  +    {
  +    }
   
       /**
        * Indicate whether this entry is a directory.
  @@ -205,17 +208,17 @@
       public byte[] getLocalFileDataData()
       {
           // CRC will be added later
  -        byte[] data = new byte[getLocalFileDataLength().getValue() - 4];
  +        byte[] data = new byte[ getLocalFileDataLength().getValue() - 4 ];
           System.arraycopy( ( new ZipShort( getMode() ) ).getBytes(), 0, data, 0, 2 );
   
           byte[] linkArray = getLinkedFile().getBytes();
           System.arraycopy( ( new ZipLong( linkArray.length ) ).getBytes(),
  -            0, data, 2, 4 );
  +                          0, data, 2, 4 );
   
           System.arraycopy( ( new ZipShort( getUserId() ) ).getBytes(),
  -            0, data, 6, 2 );
  +                          0, data, 6, 2 );
           System.arraycopy( ( new ZipShort( getGroupId() ) ).getBytes(),
  -            0, data, 8, 2 );
  +                          0, data, 8, 2 );
   
           System.arraycopy( linkArray, 0, data, 10, linkArray.length );
   
  @@ -223,7 +226,7 @@
           crc.update( data );
           long checksum = crc.getValue();
   
  -        byte[] result = new byte[data.length + 4];
  +        byte[] result = new byte[ data.length + 4 ];
           System.arraycopy( ( new ZipLong( checksum ) ).getBytes(), 0, result, 0, 4 );
           System.arraycopy( data, 0, result, 4, data.length );
           return result;
  @@ -239,11 +242,11 @@
       public ZipShort getLocalFileDataLength()
       {
           return new ZipShort( 4// CRC
  -         + 2// Mode
  -         + 4// SizDev
  -         + 2// UID
  -         + 2// GID
  -         + getLinkedFile().getBytes().length );
  +                             + 2// Mode
  +                             + 4// SizDev
  +                             + 2// UID
  +                             + 2// GID
  +                             + getLinkedFile().getBytes().length );
       }
   
       /**
  @@ -304,7 +307,7 @@
       {
   
           long givenChecksum = ( new ZipLong( data, offset ) ).getValue();
  -        byte[] tmp = new byte[length - 4];
  +        byte[] tmp = new byte[ length - 4 ];
           System.arraycopy( data, offset + 4, tmp, 0, length - 4 );
           crc.reset();
           crc.update( tmp );
  @@ -312,13 +315,13 @@
           if( givenChecksum != realChecksum )
           {
               throw new ZipException( "bad CRC checksum "
  -                 + Long.toHexString( givenChecksum )
  -                 + " instead of "
  -                 + Long.toHexString( realChecksum ) );
  +                                    + Long.toHexString( givenChecksum )
  +                                    + " instead of "
  +                                    + Long.toHexString( realChecksum ) );
           }
   
           int newMode = ( new ZipShort( tmp, 0 ) ).getValue();
  -        byte[] linkArray = new byte[( int )( new ZipLong( tmp, 2 ) ).getValue()];
  +        byte[] linkArray = new byte[ (int)( new ZipLong( tmp, 2 ) ).getValue() ];
           uid = ( new ZipShort( tmp, 6 ) ).getValue();
           gid = ( new ZipShort( tmp, 8 ) ).getValue();
   
  
  
  
  1.2       +1 -1      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/UnrecognizedExtraField.java
  
  Index: UnrecognizedExtraField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/UnrecognizedExtraField.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UnrecognizedExtraField.java	2001/12/15 12:06:33	1.1
  +++ UnrecognizedExtraField.java	2001/12/22 12:47:28	1.2
  @@ -14,7 +14,7 @@
    * told the opposite.</p>
    *
    * @author <a href="stefan.bodewig@epost.de">Stefan Bodewig</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class UnrecognizedExtraField implements ZipExtraField
   {
  @@ -92,7 +92,7 @@
   
       public void parseFromLocalFileData( byte[] data, int offset, int length )
       {
  -        byte[] tmp = new byte[length];
  +        byte[] tmp = new byte[ length ];
           System.arraycopy( data, offset, tmp, 0, length );
           setLocalFileDataData( tmp );
       }
  
  
  
  1.3       +13 -12    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/ZipEntry.java
  
  Index: ZipEntry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/ZipEntry.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ZipEntry.java	2001/12/21 14:21:24	1.2
  +++ ZipEntry.java	2001/12/22 12:47:28	1.3
  @@ -6,6 +6,7 @@
    * the LICENSE file.
    */
   package org.apache.tools.zip;
  +
   import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
   import java.util.ArrayList;
  @@ -16,7 +17,7 @@
    * the internal and external file attributes.
    *
    * @author <a href="stefan.bodewig@epost.de">Stefan Bodewig</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class ZipEntry extends java.util.zip.ZipEntry
   {
  @@ -120,7 +121,7 @@
       public ZipEntry( ZipEntry entry )
           throws ZipException
       {
  -        this( ( java.util.zip.ZipEntry )entry );
  +        this( (java.util.zip.ZipEntry)entry );
           setInternalAttributes( entry.getInternalAttributes() );
           setExternalAttributes( entry.getExternalAttributes() );
           setExtraFields( entry.getExtraFields() );
  @@ -142,7 +143,7 @@
                   {
                       setCompressedSizeMethod =
                           java.util.zip.ZipEntry.class.getMethod( "setCompressedSize",
  -                        new Class[]{Long.TYPE} );
  +                                                                new Class[]{Long.TYPE} );
                   }
                   catch( NoSuchMethodException nse )
                   {
  @@ -181,14 +182,14 @@
           {
               Throwable nested = ite.getTargetException();
               throw new RuntimeException( "Exception setting the compressed size "
  -                 + "of " + ze + ": "
  -                 + nested.getMessage() );
  +                                        + "of " + ze + ": "
  +                                        + nested.getMessage() );
           }
           catch( Throwable other )
           {
               throw new RuntimeException( "Exception setting the compressed size "
  -                 + "of " + ze + ": "
  -                 + other.getMessage() );
  +                                        + "of " + ze + ": "
  +                                        + other.getMessage() );
           }
       }
   
  @@ -255,7 +256,7 @@
           extraFields.clear();
           for( int i = 0; i < fields.length; i++ )
           {
  -            extraFields.add( fields[i] );
  +            extraFields.add( fields[ i ] );
           }
           setExtra();
       }
  @@ -341,7 +342,7 @@
       public byte[] getLocalFileDataExtra()
       {
           byte[] extra = getExtra();
  -        return extra != null ? extra : new byte[0];
  +        return extra != null ? extra : new byte[ 0 ];
       }
   
       /**
  @@ -357,7 +358,7 @@
           boolean done = false;
           for( int i = 0; !done && i < extraFields.size(); i++ )
           {
  -            if( ( ( ZipExtraField )extraFields.get( i ) ).getHeaderId().equals( type ) )
  +            if( ( (ZipExtraField)extraFields.get( i ) ).getHeaderId().equals( type ) )
               {
                   extraFields.set( i, ze );
                   done = true;
  @@ -381,7 +382,7 @@
           ZipEntry e = null;
           try
           {
  -            e = new ZipEntry( ( java.util.zip.ZipEntry )super.clone() );
  +            e = new ZipEntry( (java.util.zip.ZipEntry)super.clone() );
           }
           catch( Exception ex )
           {
  @@ -405,7 +406,7 @@
           boolean done = false;
           for( int i = 0; !done && i < extraFields.size(); i++ )
           {
  -            if( ( ( ZipExtraField )extraFields.get( i ) ).getHeaderId().equals( type ) )
  +            if( ( (ZipExtraField)extraFields.get( i ) ).getHeaderId().equals( type ) )
               {
                   extraFields.remove( i );
                   done = true;
  
  
  
  1.2       +2 -1      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/ZipExtraField.java
  
  Index: ZipExtraField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/ZipExtraField.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ZipExtraField.java	2001/12/15 12:06:33	1.1
  +++ ZipExtraField.java	2001/12/22 12:47:28	1.2
  @@ -6,6 +6,7 @@
    * the LICENSE file.
    */
   package org.apache.tools.zip;
  +
   import java.util.zip.ZipException;
   
   /**
  @@ -17,7 +18,7 @@
    * will only use the local file data in both places.</p>
    *
    * @author <a href="stefan.bodewig@epost.de">Stefan Bodewig</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public interface ZipExtraField
   {
  
  
  
  1.2       +11 -11    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/ZipLong.java
  
  Index: ZipLong.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/ZipLong.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ZipLong.java	2001/12/15 12:06:33	1.1
  +++ ZipLong.java	2001/12/22 12:47:28	1.2
  @@ -12,7 +12,7 @@
    * the big endian byte order of ZIP files.
    *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class ZipLong implements Cloneable
   {
  @@ -50,10 +50,10 @@
        */
       public ZipLong( byte[] bytes, int offset )
       {
  -        value = ( bytes[offset + 3] << 24 ) & 0xFF000000l;
  -        value += ( bytes[offset + 2] << 16 ) & 0xFF0000;
  -        value += ( bytes[offset + 1] << 8 ) & 0xFF00;
  -        value += ( bytes[offset] & 0xFF );
  +        value = ( bytes[ offset + 3 ] << 24 ) & 0xFF000000l;
  +        value += ( bytes[ offset + 2 ] << 16 ) & 0xFF0000;
  +        value += ( bytes[ offset + 1 ] << 8 ) & 0xFF00;
  +        value += ( bytes[ offset ] & 0xFF );
       }
   
       /**
  @@ -64,11 +64,11 @@
        */
       public byte[] getBytes()
       {
  -        byte[] result = new byte[4];
  -        result[0] = ( byte )( ( value & 0xFF ) );
  -        result[1] = ( byte )( ( value & 0xFF00 ) >> 8 );
  -        result[2] = ( byte )( ( value & 0xFF0000 ) >> 16 );
  -        result[3] = ( byte )( ( value & 0xFF000000l ) >> 24 );
  +        byte[] result = new byte[ 4 ];
  +        result[ 0 ] = (byte)( ( value & 0xFF ) );
  +        result[ 1 ] = (byte)( ( value & 0xFF00 ) >> 8 );
  +        result[ 2 ] = (byte)( ( value & 0xFF0000 ) >> 16 );
  +        result[ 3 ] = (byte)( ( value & 0xFF000000l ) >> 24 );
           return result;
       }
   
  @@ -96,7 +96,7 @@
           {
               return false;
           }
  -        return value == ( ( ZipLong )o ).getValue();
  +        return value == ( (ZipLong)o ).getValue();
       }
   
       /**
  @@ -107,7 +107,7 @@
        */
       public int hashCode()
       {
  -        return ( int )value;
  +        return (int)value;
       }
   
   }// ZipLong
  
  
  
  1.3       +24 -23    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/ZipOutputStream.java
  
  Index: ZipOutputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/ZipOutputStream.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ZipOutputStream.java	2001/12/21 14:21:24	1.2
  +++ ZipOutputStream.java	2001/12/22 12:47:28	1.3
  @@ -6,12 +6,13 @@
    * the LICENSE file.
    */
   package org.apache.tools.zip;
  +
   import java.io.IOException;
   import java.io.OutputStream;
   import java.io.UnsupportedEncodingException;
  +import java.util.ArrayList;
   import java.util.Date;
   import java.util.Hashtable;
  -import java.util.ArrayList;
   import java.util.zip.CRC32;
   import java.util.zip.Deflater;
   import java.util.zip.DeflaterOutputStream;
  @@ -30,7 +31,7 @@
    * #putNextEntry putNextEntry} will be called.</p>
    *
    * @author <a href="stefan.bodewig@epost.de">Stefan Bodewig</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class ZipOutputStream extends DeflaterOutputStream
   {
  @@ -216,17 +217,17 @@
               return DOS_TIME_MIN;
           }
           long value = ( ( year - 1980 ) << 25 )
  -             | ( month << 21 )
  -             | ( time.getDate() << 16 )
  -             | ( time.getHours() << 11 )
  -             | ( time.getMinutes() << 5 )
  -             | ( time.getSeconds() >> 1 );
  -
  -        byte[] result = new byte[4];
  -        result[0] = ( byte )( ( value & 0xFF ) );
  -        result[1] = ( byte )( ( value & 0xFF00 ) >> 8 );
  -        result[2] = ( byte )( ( value & 0xFF0000 ) >> 16 );
  -        result[3] = ( byte )( ( value & 0xFF000000l ) >> 24 );
  +            | ( month << 21 )
  +            | ( time.getDate() << 16 )
  +            | ( time.getHours() << 11 )
  +            | ( time.getMinutes() << 5 )
  +            | ( time.getSeconds() >> 1 );
  +
  +        byte[] result = new byte[ 4 ];
  +        result[ 0 ] = (byte)( ( value & 0xFF ) );
  +        result[ 1 ] = (byte)( ( value & 0xFF00 ) >> 8 );
  +        result[ 2 ] = (byte)( ( value & 0xFF0000 ) >> 16 );
  +        result[ 3 ] = (byte)( ( value & 0xFF000000l ) >> 24 );
           return new ZipLong( result );
       }
   
  @@ -332,19 +333,19 @@
               if( entry.getCrc() != realCrc )
               {
                   throw new ZipException( "bad CRC checksum for entry "
  -                     + entry.getName() + ": "
  -                     + Long.toHexString( entry.getCrc() )
  -                     + " instead of "
  -                     + Long.toHexString( realCrc ) );
  +                                        + entry.getName() + ": "
  +                                        + Long.toHexString( entry.getCrc() )
  +                                        + " instead of "
  +                                        + Long.toHexString( realCrc ) );
               }
   
               if( entry.getSize() != written - dataStart )
               {
                   throw new ZipException( "bad size for entry "
  -                     + entry.getName() + ": "
  -                     + entry.getSize()
  -                     + " instead of "
  -                     + ( written - dataStart ) );
  +                                        + entry.getName() + ": "
  +                                        + entry.getSize()
  +                                        + " instead of "
  +                                        + ( written - dataStart ) );
               }
   
           }
  @@ -372,7 +373,7 @@
           cdOffset = new ZipLong( written );
           for( int i = 0; i < entries.size(); i++ )
           {
  -            writeCentralFileHeader( ( ZipEntry )entries.get( i ) );
  +            writeCentralFileHeader( (ZipEntry)entries.get( i ) );
           }
           cdLength = new ZipLong( written - cdOffset.getValue() );
           writeCentralDirectoryEnd();
  @@ -593,7 +594,7 @@
           written += 4;
   
           // relative offset of LFH
  -        out.write( ( ( ZipLong )offsets.get( ze ) ).getBytes() );
  +        out.write( ( (ZipLong)offsets.get( ze ) ).getBytes() );
           written += 4;
   
           // file name
  
  
  
  1.2       +6 -6      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/ZipShort.java
  
  Index: ZipShort.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/zip/ZipShort.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ZipShort.java	2001/12/15 12:06:33	1.1
  +++ ZipShort.java	2001/12/22 12:47:28	1.2
  @@ -12,7 +12,7 @@
    * the big endian byte order of ZIP files.
    *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class ZipShort implements Cloneable
   {
  @@ -50,8 +50,8 @@
        */
       public ZipShort( byte[] bytes, int offset )
       {
  -        value = ( bytes[offset + 1] << 8 ) & 0xFF00;
  -        value += ( bytes[offset] & 0xFF );
  +        value = ( bytes[ offset + 1 ] << 8 ) & 0xFF00;
  +        value += ( bytes[ offset ] & 0xFF );
       }
   
       /**
  @@ -62,9 +62,9 @@
        */
       public byte[] getBytes()
       {
  -        byte[] result = new byte[2];
  -        result[0] = ( byte )( value & 0xFF );
  -        result[1] = ( byte )( ( value & 0xFF00 ) >> 8 );
  +        byte[] result = new byte[ 2 ];
  +        result[ 0 ] = (byte)( value & 0xFF );
  +        result[ 1 ] = (byte)( ( value & 0xFF00 ) >> 8 );
           return result;
       }
   
  @@ -92,7 +92,7 @@
           {
               return false;
           }
  -        return value == ( ( ZipShort )o ).getValue();
  +        return value == ( (ZipShort)o ).getValue();
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>