Class CancellableDigestOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.eclipse.jgit.internal.storage.io.CancellableDigestOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
- Direct Known Subclasses:
PackOutputStream
public class CancellableDigestOutputStream extends java.io.OutputStream
An OutputStream that keeps a digest and checks every N bytes for cancellation.
-
-
Field Summary
Fields Modifier and Type Field Description static int
BYTES_TO_WRITE_BEFORE_CANCEL_CHECK
The OutputStream checks every this value for cancellationprivate long
checkCancelAt
private long
count
private java.security.MessageDigest
md
private java.io.OutputStream
out
private ProgressMonitor
writeMonitor
-
Constructor Summary
Constructors Constructor Description CancellableDigestOutputStream(ProgressMonitor writeMonitor, java.io.OutputStream out)
Initialize a CancellableDigestOutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
byte[]
getDigest()
Obtain the current SHA-1 digest.ProgressMonitor
getWriteMonitor()
Get the monitor which is used to update on output progress and check cancel.long
length()
Get total number of bytes written since stream start.void
write(byte[] b, int off, int len)
void
write(int b)
-
-
-
Field Detail
-
BYTES_TO_WRITE_BEFORE_CANCEL_CHECK
public static final int BYTES_TO_WRITE_BEFORE_CANCEL_CHECK
The OutputStream checks every this value for cancellation- See Also:
- Constant Field Values
-
writeMonitor
private final ProgressMonitor writeMonitor
-
out
private final java.io.OutputStream out
-
md
private final java.security.MessageDigest md
-
count
private long count
-
checkCancelAt
private long checkCancelAt
-
-
Constructor Detail
-
CancellableDigestOutputStream
public CancellableDigestOutputStream(ProgressMonitor writeMonitor, java.io.OutputStream out)
Initialize a CancellableDigestOutputStream.- Parameters:
writeMonitor
- monitor to update on output progress and check cancel.out
- target stream to receive all contents.
-
-
Method Detail
-
getWriteMonitor
public final ProgressMonitor getWriteMonitor()
Get the monitor which is used to update on output progress and check cancel.- Returns:
- the monitor
-
getDigest
public final byte[] getDigest()
Obtain the current SHA-1 digest.- Returns:
- SHA-1 digest
-
length
public final long length()
Get total number of bytes written since stream start.- Returns:
- total number of bytes written since stream start.
-
write
public final void write(int b) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public final void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
-