public abstract class ChecksumChecker
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
CHECKSUM_CRC |
| Constructor and Description |
|---|
ChecksumChecker() |
| Modifier and Type | Method and Description |
|---|---|
abstract byte[] |
appendChecksum(byte[] data) |
abstract boolean |
checkChecksum(byte[] data,
int offset,
int length,
byte[] checksum)
Verify a checksum or report.
|
abstract int |
checksumLength()
Get the length of the checksum
|
java.io.InputStream |
checksumReaderWithLength(java.io.InputStream dis,
BucketFactory bf,
long maxLength) |
java.io.OutputStream |
checksumWriter(java.io.OutputStream os) |
abstract java.io.OutputStream |
checksumWriter(java.io.OutputStream os,
int skipPrefix)
Get an OutputStream that will write a checksum when closed.
|
PrependLengthOutputStream |
checksumWriterWithLength(java.io.OutputStream dos,
BucketFactory bf)
Get an OutputStream that will write to a temporary Bucket, append a checksum and prepend a
length.
|
abstract void |
copyAndStripChecksum(java.io.InputStream is,
java.io.OutputStream os,
long length)
Copy bytes from one stream to another, verifying and stripping the final checksum.
|
static ChecksumChecker |
create(int checksumID)
Create a ChecksumChecker of the specified type.
|
byte[] |
generateChecksum(byte[] bufToChecksum) |
abstract byte[] |
generateChecksum(byte[] bufToChecksum,
int offset,
int length) |
abstract int |
getChecksumTypeID() |
int |
lengthAndChecksumOverhead() |
abstract void |
readAndChecksum(java.io.DataInput is,
byte[] buf,
int offset,
int length)
Read from disk and verify the checksum that follows the data.
|
void |
verifyChecksum(byte[] data,
int offset,
int length,
byte[] checksum)
Verify a checksum or throw
|
void |
writeAndChecksum(java.io.ObjectOutputStream oos,
byte[] buf) |
void |
writeAndChecksum(java.io.OutputStream os,
byte[] buf,
int offset,
int length) |
public static final int CHECKSUM_CRC
public abstract int checksumLength()
public abstract java.io.OutputStream checksumWriter(java.io.OutputStream os,
int skipPrefix)
public java.io.OutputStream checksumWriter(java.io.OutputStream os)
public PrependLengthOutputStream checksumWriterWithLength(java.io.OutputStream dos, BucketFactory bf) throws java.io.IOException
os - The underlying stream, which will not be closed.bf - Used to allocate temporary storage.java.io.IOExceptionpublic abstract byte[] appendChecksum(byte[] data)
public void verifyChecksum(byte[] data,
int offset,
int length,
byte[] checksum)
throws ChecksumFailedException
ChecksumFailedExceptionpublic abstract boolean checkChecksum(byte[] data,
int offset,
int length,
byte[] checksum)
public abstract byte[] generateChecksum(byte[] bufToChecksum,
int offset,
int length)
public byte[] generateChecksum(byte[] bufToChecksum)
public abstract int getChecksumTypeID()
public abstract void copyAndStripChecksum(java.io.InputStream is,
java.io.OutputStream os,
long length)
throws java.io.IOException,
ChecksumFailedException
java.io.IOExceptionChecksumFailedExceptionpublic abstract void readAndChecksum(java.io.DataInput is,
byte[] buf,
int offset,
int length)
throws java.io.IOException,
ChecksumFailedException
java.io.IOExceptionChecksumFailedExceptionpublic java.io.InputStream checksumReaderWithLength(java.io.InputStream dis,
BucketFactory bf,
long maxLength)
throws java.io.IOException,
ChecksumFailedException
java.io.IOExceptionChecksumFailedExceptionpublic void writeAndChecksum(java.io.OutputStream os,
byte[] buf,
int offset,
int length)
throws java.io.IOException
java.io.IOExceptionpublic void writeAndChecksum(java.io.ObjectOutputStream oos,
byte[] buf)
throws java.io.IOException
java.io.IOExceptionpublic int lengthAndChecksumOverhead()
public static ChecksumChecker create(int checksumID)
checksumID - The checksum type.java.lang.IllegalArgumentException - If there is no ChecksumChecker for that ID.