maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject cvs commit: maven-wagon/wagon-api/src/main/java/org/apache/maven/wagon/observers Md5SumObserver.java
Date Sun, 16 May 2004 17:16:18 GMT
michal      2004/05/16 10:16:18

  Modified:    wagon-api/src/main/java/org/apache/maven/wagon/observers
                        Md5SumObserver.java
  Log:
  Added encode method. This dupliacted the code in MD5Verifier. We need to clean those things
up. At the moment we are just experimenting
  
  Revision  Changes    Path
  1.2       +38 -9     maven-wagon/wagon-api/src/main/java/org/apache/maven/wagon/observers/Md5SumObserver.java
  
  Index: Md5SumObserver.java
  ===================================================================
  RCS file: /home/cvs/maven-wagon/wagon-api/src/main/java/org/apache/maven/wagon/observers/Md5SumObserver.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Md5SumObserver.java	26 Apr 2004 19:23:43 -0000	1.1
  +++ Md5SumObserver.java	16 May 2004 17:16:18 -0000	1.2
  @@ -50,17 +50,12 @@
   
       public void transferCompleted( TransferEvent transferEvent )
       {
  -        // here we can do we need to have possibility to transfer to memory:
  -        //Wagon wagon = transferEvent.getWagon();
  -        //
  -        //String resource transferEvent.getResource();
  -        //
  -        //String md5 = wagon.getToString( resource + ".md5" );
  +        
       }
   
       public void transferError( TransferEvent transferEvent )
       {
  -        // TODO Auto-generated method stub
  +        
           
       }
   
  @@ -76,11 +71,45 @@
          
          if ( md5Digester != null )
          {
  -           retValue = new String ( md5Digester.digest() );
  +           retValue = encode ( md5Digester.digest() );
          }
          
          return retValue;
          
       }
  +    
  +    /**
  +     * Encodes a 128 bit (16 bytes) byte array into a 32 character String.
  +     * XXX I think it should at least throw an IllegalArgumentException rather than return
null
  +     *
  +     * @param binaryData Array containing the digest
  +     * @return Encoded hex string, or null if encoding failed
  +     */
  +    protected String encode( byte[] binaryData )
  +    {
  +        if ( binaryData.length != 16 )
  +        {
  +            return null;
  +        }
  +
  +        String result = "";
  +
  +        for ( int i = 0; i < 16; i++ )
  +        {
  +            String t = Integer.toHexString( binaryData[i] & 0xff );
  +
  +            if ( t.length() == 1 )
  +            {
  +                result += ( "0" + t );
  +            }
  +            else
  +            {
  +                result += t;
  +            }
  +        }
  +
  +        return result;
  +    }
  +    
       
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-cvs-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-cvs-help@maven.apache.org


Mime
View raw message