1 26 27 package net.sourceforge.groboutils.codecoverage.v2.util; 28 29 import java.util.Comparator ; 30 import java.util.zip.CRC32 ; 31 import java.util.zip.Checksum ; 32 33 34 45 public class ChecksumUtil 46 { 47 protected static ChecksumUtil s_instance = new ChecksumUtil(); 48 49 protected final Comparator StringCollator = 52 java.text.Collator.getInstance(new java.util.Locale ("en", "US", "")); 53 54 57 protected ChecksumUtil() 58 { 59 } 61 62 63 public static ChecksumUtil getInstance() 64 { 65 return s_instance; 66 } 67 68 69 70 public long checksum( byte[] buff ) 71 { 72 Checksum crc = createChecksum(); 73 update( crc, buff ); 74 return crc.getValue(); 75 } 76 77 78 86 87 88 96 97 98 106 107 108 116 117 118 126 127 128 129 132 protected Checksum createChecksum() 133 { 134 return new CRC32 (); 135 } 136 137 138 protected void update( Checksum crc, byte[] buff ) 139 { 140 if (buff != null) 141 { 142 crc.update( buff, 0, buff.length ); 143 } 144 } 145 146 147 193 194 229 230 236 237 247 248 249 257 258 259 273 } 274 | Popular Tags |