Class PackOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.eclipse.jgit.internal.storage.pack.PackOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public final class PackOutputStream extends java.io.OutputStreamCustom output stream to supportPackWriter.
-
-
Field Summary
Fields Modifier and Type Field Description private static intBYTES_TO_WRITE_BEFORE_CANCEL_CHECKprivate longcheckCancelAtprivate byte[]copyBufferprivate longcountprivate byte[]headerBufferprivate java.security.MessageDigestmdprivate booleanofsDeltaprivate java.io.OutputStreamoutprivate PackWriterpackWriterprivate ProgressMonitorwriteMonitor
-
Constructor Summary
Constructors Constructor Description PackOutputStream(ProgressMonitor writeMonitor, java.io.OutputStream out, PackWriter pw)Initialize a pack output stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidendObject()voidflush()byte[]getCopyBuffer()Get a temporary buffer writers can use to copy data with.(package private) byte[]getDigest()longlength()Get total number of bytes written since stream start.private static intobjectHeader(long len, int type, byte[] buf)private static intofsDelta(long diff, byte[] buf, int p)private static intofsDeltaVarIntLength(long v)voidwrite(byte[] b, int off, int len)voidwrite(int b)(package private) voidwriteFileHeader(int version, long objectCount)voidwriteHeader(ObjectToPack otp, long rawLength)Commits the object header onto the stream.voidwriteObject(ObjectToPack otp)Write one object.
-
-
-
Field Detail
-
BYTES_TO_WRITE_BEFORE_CANCEL_CHECK
private static final int BYTES_TO_WRITE_BEFORE_CANCEL_CHECK
- See Also:
- Constant Field Values
-
writeMonitor
private final ProgressMonitor writeMonitor
-
out
private final java.io.OutputStream out
-
packWriter
private final PackWriter packWriter
-
md
private final java.security.MessageDigest md
-
count
private long count
-
headerBuffer
private final byte[] headerBuffer
-
copyBuffer
private final byte[] copyBuffer
-
checkCancelAt
private long checkCancelAt
-
ofsDelta
private boolean ofsDelta
-
-
Constructor Detail
-
PackOutputStream
public PackOutputStream(ProgressMonitor writeMonitor, java.io.OutputStream out, PackWriter pw)
Initialize a pack output stream.This constructor is exposed to support debugging the JGit library only. Application or storage level code should not create a PackOutputStream, instead use
PackWriter, and let the writer create the stream.- Parameters:
writeMonitor- monitor to update on object output progress.out- target stream to receive all object contents.pw- packer that is going to perform the output.
-
-
Method Detail
-
write
public final void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public final void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException
-
writeFileHeader
final void writeFileHeader(int version, long objectCount) throws java.io.IOException- Throws:
java.io.IOException
-
writeObject
public final void writeObject(ObjectToPack otp) throws java.io.IOException
Write one object. If the object was already written, this method does nothing and returns quickly. This case occurs whenever an object was written out of order in order to ensure the delta base occurred before the object that needs it.- Parameters:
otp- the object to write.- Throws:
java.io.IOException- the object cannot be read from the object reader, or the output stream is no longer accepting output. Caller must examine the type of exception and possibly its message to distinguish between these cases.
-
writeHeader
public final void writeHeader(ObjectToPack otp, long rawLength) throws java.io.IOException
Commits the object header onto the stream.Once the header has been written, the object representation must be fully output, or packing must abort abnormally.
- Parameters:
otp- the object to pack. Header information is obtained.rawLength- number of bytes of the inflated content. For an object that is in whole object format, this is the same as the object size. For an object that is in a delta format, this is the size of the inflated delta instruction stream.- Throws:
java.io.IOException- the underlying stream refused to accept the header.
-
objectHeader
private static final int objectHeader(long len, int type, byte[] buf)
-
ofsDelta
private static final int ofsDelta(long diff, byte[] buf, int p)
-
ofsDeltaVarIntLength
private static final int ofsDeltaVarIntLength(long v)
-
getCopyBuffer
public final byte[] getCopyBuffer()
Get a temporary buffer writers can use to copy data with.- Returns:
- a temporary buffer writers can use to copy data with.
-
endObject
void endObject()
-
length
public final long length()
Get total number of bytes written since stream start.- Returns:
- total number of bytes written since stream start.
-
getDigest
final byte[] getDigest()
- Returns:
- obtain the current SHA-1 digest.
-
-