Package org.syncany.chunk
Class Fingerprinter
- java.lang.Object
-
- org.syncany.chunk.Fingerprinter
-
- Direct Known Subclasses:
Adler32Fingerprinter
public abstract class Fingerprinter extends java.lang.Object
A fingerprinter is used in content basedChunker
s to determine at which byte to break a file intoChunk
s.Implementations should make sure that the underlying algorithm is fast, because the
roll()
-method is called for each byte of a file. It should rely on a rolling checksum algorithm (also: rolling hash) to reach optimal performance.
-
-
Constructor Summary
Constructors Constructor Description Fingerprinter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
check(byte[] buf, int off, int len)
Update the checksum with an entirely different block, and potentially a different block length.static Fingerprinter
getInstance(java.lang.String name)
abstract int
getValue()
Return the value of the currently computed checksum.abstract void
reset()
Reset the checksum.abstract void
roll(byte bt)
"Roll" the checksum, i.e.abstract java.lang.String
toString()
Returns a string representation of the fingerprinter implementation.
-
-
-
Constructor Detail
-
Fingerprinter
public Fingerprinter()
-
-
Method Detail
-
getInstance
public static Fingerprinter getInstance(java.lang.String name) throws java.security.NoSuchAlgorithmException
- Throws:
java.security.NoSuchAlgorithmException
-
getValue
public abstract int getValue()
Return the value of the currently computed checksum.- Returns:
- The currently computed checksum.
-
reset
public abstract void reset()
Reset the checksum.
-
roll
public abstract void roll(byte bt)
"Roll" the checksum, i.e. update the underlying rolling checksum by the given content byte.- Parameters:
bt
- The next byte.
-
check
public abstract void check(byte[] buf, int off, int len)
Update the checksum with an entirely different block, and potentially a different block length.- Parameters:
buf
- The byte array that holds the new block.off
- From whence to begin reading.len
- The length of the block to read.
-
toString
public abstract java.lang.String toString()
Returns a string representation of the fingerprinter implementation.- Overrides:
toString
in classjava.lang.Object
-
-