java.util.zip

Interface Checksum

Known Implementing Classes:
Adler32, CRC32

public interface Checksum

An interface representing a data checksum.

Method Summary

long
getValue()
Returns the current checksum value.
void
reset()
Resets the checksum to its initial value.
void
update(byte[] b, int off, int len)
Updates the current checksum with the specified array of bytes.
void
update(int b)
Updates the current checksum with the specified byte.

Method Details

getValue

public long getValue()
Returns the current checksum value.
Returns:
the current checksum value
Usages and Demos :

View More Examples of getValue()
   1: import java.util.zip.CRC32;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5: {
   6:     private Checksum checksum = new CRC32();
   7:     
   8:         ...
   9:     {
  10:         return checksum.getValue();
  11:     }

View Full Code Here
   1: import java.util.zip.Adler32;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5:     public static long compute(byte[] data, int start, int length) {
   6:         Checksum checksum = new Adler32();
   7:         checksum.update(data, start, length);
   8:         ...
   9:         return checksum.getValue();
  10:     }

View Full Code Here
   1:     private long current;
   2:     private Checksum checksum;
   3:     private TLongLongHashMap checksums;
   4:         ...
   5:     {
   6:         this.checksum = new CRC32();
   7:         this.checksums = new TLongLongHashMap();
   8:         ...
   9:         boolean proceed = false;
  10:         long value = checksum.getValue();
  11:         long expected = checksums.get(current);

View Full Code Here
   1: import java.util.zip.CheckedInputStream;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5:         FileInputStream is = null;
   6:         Checksum checksum = new Adler32();
   7:         byte[] tempBuf = new byte[128];
   8:         ...
   9:         }
  10:         return checksum.getValue();
  11:     }

View Full Code Here
   1: import java.io.File;
   2: import java.util.zip.Checksum;
   3: import org.apache.tools.ant.BuildException;
   4:         ...
   5:     private final TIntLongHashMap citationSources = new TIntLongHashMap();
   6:     private final Checksum checksum = new CRC64();
   7:     private File path;
   8:         ...
   9:                 updateChecksum(author);
  10:         return checksum.getValue();
  11:     }

View Full Code Here

reset

public void reset()
Resets the checksum to its initial value.
Usages and Demos :

View More Examples of reset()
   1: import java.util.zip.CRC32;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5: {
   6:     private Checksum checksum = new CRC32();
   7:     
   8:         ...
   9:     {
  10:         checksum.reset();
  11:     }

View Full Code Here
   1:     private long current;
   2:     private Checksum checksum;
   3:     private TLongLongHashMap checksums;
   4:         ...
   5:     {
   6:         this.checksum = new CRC32();
   7:         this.checksums = new TLongLongHashMap();
   8:         ...
   9:         current = 0;
  10:         checksum.reset();
  11:         

View Full Code Here
   1: import java.io.File;
   2: import java.util.zip.Checksum;
   3: import org.apache.tools.ant.BuildException;
   4:         ...
   5:     private final TIntLongHashMap citationSources = new TIntLongHashMap();
   6:     private final Checksum checksum = new CRC64();
   7:     private File path;
   8:         ...
   9:     {
  10:         checksum.reset();
  11:         if (citation.getTitle() != null)

View Full Code Here
   1: import java.nio.ByteBuffer;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5: 
   6:     private Checksum cksum;
   7: 
   8:         ...
   9:     void reset() {
  10:         cksum.reset();
  11:     }
  12:         ...
  13:         ((anticipateChecksumErrors ? null : env),
  14:          "null buffer given to checksum validation, probably " +

View Full Code Here
   1: {
   2:     private Checksum checksum;
   3:     private File source;
   4:         ...
   5:     {
   6:         this.checksum = new CRC32();
   7:         this.source = source;
   8:         ...
   9:         current = 0;
  10:         checksum.reset();
  11:         

View Full Code Here

update

public void update(byte[] b,
                   int off,
                   int len)
Updates the current checksum with the specified array of bytes.
Parameters:
b - the byte array to update the checksum with
off - the start offset of the data
len - the number of bytes to use for the update
Usages and Demos :

View More Examples of update(byte[] b,int off,int len)
   1: import java.util.zip.CRC32;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5: {
   6:     private Checksum checksum = new CRC32();
   7:     
   8:         ...
   9:             byte[] bytes = object.toString().getBytes();
  10:             checksum.update(bytes, 0, bytes.length);
  11:         }

View Full Code Here
   1: import java.util.zip.Adler32;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5:     public static long compute(byte[] data, int start, int length) {
   6:         Checksum checksum = new Adler32();
   7:         ...
   8:         checksum.update(data, start, length);
   9:         return checksum.getValue();

View Full Code Here
   1:     private long current;
   2:     private Checksum checksum;
   3:     private TLongLongHashMap checksums;
   4:         ...
   5:     {
   6:         this.checksum = new CRC32();
   7:         this.checksums = new TLongLongHashMap();
   8:         ...
   9:             byte[] bytes = object.toString().getBytes();
  10:             checksum.update(bytes, 0, bytes.length);
  11:         }

View Full Code Here
   1: import java.io.File;
   2: import java.util.zip.Checksum;
   3: import org.apache.tools.ant.BuildException;
   4:         ...
   5:     private final TIntLongHashMap citationSources = new TIntLongHashMap();
   6:     private final Checksum checksum = new CRC64();
   7:     private File path;
   8:         ...
   9:         byte[] bytes = s.getBytes();
  10:         checksum.update(bytes, 0, bytes.length);
  11:     }

View Full Code Here
   1: {
   2:     private Checksum checksum;
   3:     private File source;
   4:         ...
   5:     {
   6:         this.checksum = new CRC32();
   7:         this.source = source;
   8:         ...
   9:             byte[] bytes = object.toString().getBytes();
  10:             checksum.update(bytes, 0, bytes.length);
  11:         }

View Full Code Here

update

public void update(int b)
Updates the current checksum with the specified byte.
Parameters:
b - the byte to update the checksum with
Usages and Demos :

View More Examples of update(int b)
   1: import java.nio.ByteBuffer;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5: 
   6:     private Checksum cksum;
   7: 
   8:         ...
   9:         ((anticipateChecksumErrors ? null : env),
  10:          "null buffer given to checksum validation, probably " +
  11:          " result of 0's in log file. " + anticipateChecksumErrors);
  12:         ...
  13:         if (buf.hasArray()) {
  14:             cksum.update(buf.array(), bufStart, length);

View Full Code Here
   1: import java.util.Random;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5:     public void testRandomAdler32ByteArray() {
   6:     Checksum javaChecksum = new java.util.zip.Adler32();
   7:         ...
   8:     Checksum jeChecksum = new com.sleepycat.je.utilint.Adler32();
   9:     Random rnd = new Random();
  10:         ...
  11:         for (int j = 0; j < len; j++) {
  12:             cksum.update(b[j]);

View Full Code Here
   1: import java.util.zip.CRC32;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5:     
   6:     protected final Checksum CRC = new CRC32();
   7:     
   8:         ...
   9:             count++;
  10:             CRC.update(b);
  11:         } catch (IOException e) {

View Full Code Here
   1: import java.io.*;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5: 
   6:     private Checksum crc;
   7: 
   8:         ...
   9:         out.write(b);
  10:         crc.update((byte) b);
  11:     }

View Full Code Here
   1: import java.util.List;
   2: import java.util.zip.Checksum;
   3: 
   4:         ...
   5:         sb.append((ref.getLocation() ==null || ref.getLocation().equals(""))?"<undef>":ref.getLocation());
   6:         Checksum cs = new CRC64Checksum();
   7:         ...
   8:         cs.update(sb.toString().getBytes(), 0, sb.length());
   9:         

View Full Code Here