public final class PackOutputStream
extends java.io.OutputStream
PackWriter
.Modifier and Type | Field and Description |
---|---|
private static int |
BYTES_TO_WRITE_BEFORE_CANCEL_CHECK |
private long |
checkCancelAt |
private byte[] |
copyBuffer |
private long |
count |
private byte[] |
headerBuffer |
private java.security.MessageDigest |
md |
private boolean |
ofsDelta |
private java.io.OutputStream |
out |
private PackWriter |
packWriter |
private ProgressMonitor |
writeMonitor |
Constructor and Description |
---|
PackOutputStream(ProgressMonitor writeMonitor,
java.io.OutputStream out,
PackWriter pw)
Initialize a pack output stream.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
endObject() |
void |
flush() |
byte[] |
getCopyBuffer()
Get a temporary buffer writers can use to copy data with.
|
(package private) byte[] |
getDigest() |
long |
length()
Get total number of bytes written since stream start.
|
private static int |
objectHeader(long len,
int type,
byte[] buf) |
private static int |
ofsDelta(long diff,
byte[] buf,
int p) |
private static int |
ofsDeltaVarIntLength(long v) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
(package private) void |
writeFileHeader(int version,
long objectCount) |
void |
writeHeader(ObjectToPack otp,
long rawLength)
Commits the object header onto the stream.
|
void |
writeObject(ObjectToPack otp)
Write one object.
|
private static final int BYTES_TO_WRITE_BEFORE_CANCEL_CHECK
private final ProgressMonitor writeMonitor
private final java.io.OutputStream out
private final PackWriter packWriter
private final java.security.MessageDigest md
private long count
private final byte[] headerBuffer
private final byte[] copyBuffer
private long checkCancelAt
private boolean ofsDelta
public PackOutputStream(ProgressMonitor writeMonitor, java.io.OutputStream out, PackWriter pw)
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.
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.public final void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public final void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
final void writeFileHeader(int version, long objectCount) throws java.io.IOException
java.io.IOException
public final void writeObject(ObjectToPack otp) throws java.io.IOException
otp
- the object to write.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.public final void writeHeader(ObjectToPack otp, long rawLength) throws java.io.IOException
Once the header has been written, the object representation must be fully output, or packing must abort abnormally.
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.java.io.IOException
- the underlying stream refused to accept the header.private static final int objectHeader(long len, int type, byte[] buf)
private static final int ofsDelta(long diff, byte[] buf, int p)
private static final int ofsDeltaVarIntLength(long v)
public final byte[] getCopyBuffer()
void endObject()
public final long length()
final byte[] getDigest()