protected String hashURL ( URL url , String externalForm ) { if ( url == null ) return ERR_HASH ; String hash = path2Hash . get ( externalForm ) ; if ( hash != null ) { return hash ; } if ( mIsSemanticHashing ) { byte [ ] bytes = FileUtil . loadBytes ( url ) ; if ( bytes == null ) return ERR_HASH ; // Remove debug info from classfiles. bytes = BytecodeCleaner . removeDebugInfo ( bytes ) ; hash = hashByteArray ( bytes ) ; } else { // http://www.oracle.com/technetwork/articles/java/compress-1565076.html Checksum cksum = new Adler32 ( ) ; byte [ ] bytes = FileUtil . loadBytes ( url , cksum ) ; if ( bytes == null ) return ERR_HASH ; hash = Long . toString ( cksum . getValue ( ) ) ; } path2Hash . put ( externalForm , hash ) ; return hash ; }
Hash resource at the given URL .