Class CancellableDigestOutputStream
java.lang.Object
java.io.OutputStream
org.eclipse.jgit.internal.storage.io.CancellableDigestOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Direct Known Subclasses:
PackOutputStream
An OutputStream that keeps a digest and checks every N bytes for
cancellation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe OutputStream checks every this value for cancellationprivate longprivate longprivate final MessageDigestprivate final OutputStreamprivate final ProgressMonitor -
Constructor Summary
ConstructorsConstructorDescriptionCancellableDigestOutputStream(ProgressMonitor writeMonitor, OutputStream out) Initialize a CancellableDigestOutputStream. -
Method Summary
Modifier and TypeMethodDescriptionvoidflush()final byte[]Obtain the current SHA-1 digest.final ProgressMonitorGet the monitor which is used to update on output progress and check cancel.final longlength()Get total number of bytes written since stream start.final voidwrite(byte[] b, int off, int len) final voidwrite(int b) Methods inherited from class java.io.OutputStream
close, nullOutputStream, write
-
Field Details
-
BYTES_TO_WRITE_BEFORE_CANCEL_CHECK
public static final int BYTES_TO_WRITE_BEFORE_CANCEL_CHECKThe OutputStream checks every this value for cancellation- See Also:
-
writeMonitor
-
out
-
md
-
count
private long count -
checkCancelAt
private long checkCancelAt
-
-
Constructor Details
-
CancellableDigestOutputStream
Initialize a CancellableDigestOutputStream.- Parameters:
writeMonitor- monitor to update on output progress and check cancel.out- target stream to receive all contents.
-
-
Method Details
-
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
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-