Top Description Fields Constructors Methods
org.eclipse.jgit.internal.storage.pack

public final Class PackOutputStream

extends CancellableDigestOutputStream
Class Inheritance
Static Imports
org.eclipse.jgit.lib.Constants.OBJ_OFS_DELTA, .Constants.OBJ_REF_DELTA, .Constants.PACK_SIGNATURE

Custom output stream to support org.eclipse.jgit.internal.storage.pack.PackWriter.

Field Summary

Modifier and TypeField and Description
private final byte[]
private final byte[]
private boolean
private final PackWriter
Inherited from org.eclipse.jgit.internal.storage.io.CancellableDigestOutputStream:
BYTES_TO_WRITE_BEFORE_CANCEL_CHECK

Constructor Summary

AccessConstructor and Description
public
PackOutputStream(final ProgressMonitor
monitor to update on object output progress.
writeMonitor
,
final OutputStream
target stream to receive all object contents.
out
,
final PackWriter
packer that is going to perform the output.
pw
)

Initialize a pack output stream.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
public final byte[]

Returns:

a temporary buffer writers can use to copy data with.
getCopyBuffer
()

Get a temporary buffer writers can use to copy data with.

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
pack-priv final void
writeFileHeader(int version, long objectCount)

public final void
writeHeader(ObjectToPack
the object to pack. Header information is obtained.
otp
,
long
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.
rawLength
)

Commits the object header onto the stream.

public final void
writeObject(ObjectToPack
the object to write.
otp
)

Write one object.

Inherited from org.eclipse.jgit.internal.storage.io.CancellableDigestOutputStream:
flushgetDigestgetWriteMonitorlengthwritewrite

Field Detail

copyBufferback to summary
private final byte[] copyBuffer
headerBufferback to summary
private final byte[] headerBuffer
ofsDeltaback to summary
private boolean ofsDelta
packWriterback to summary
private final PackWriter packWriter

Constructor Detail

PackOutputStreamback to summary
public PackOutputStream(final ProgressMonitor writeMonitor, final OutputStream out, final 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 org.eclipse.jgit.internal.storage.pack.PackWriter, and let the writer create the stream.

Parameters
writeMonitor:ProgressMonitor

monitor to update on object output progress.

out:OutputStream

target stream to receive all object contents.

pw:PackWriter

packer that is going to perform the output.

Method Detail

endObjectback to summary
pack-priv void endObject()
getCopyBufferback to summary
public final byte[] getCopyBuffer()

Get a temporary buffer writers can use to copy data with.

Returns:byte[]

a temporary buffer writers can use to copy data with.

objectHeaderback to summary
private static final int objectHeader(long len, int type, byte[] buf)
ofsDeltaback to summary
private static final int ofsDelta(long diff, byte[] buf, int p)
ofsDeltaVarIntLengthback to summary
private static final int ofsDeltaVarIntLength(long v)
writeFileHeaderback to summary
pack-priv final void writeFileHeader(int version, long objectCount) throws IOException
writeHeaderback to summary
public final void writeHeader(ObjectToPack otp, long rawLength) throws 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:ObjectToPack

the object to pack. Header information is obtained.

rawLength:long

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.

Annotations
@SuppressWarnings:ShortCircuitBoolean
Exceptions
IOException:
the underlying stream refused to accept the header.
writeObjectback to summary
public final void writeObject(ObjectToPack otp) throws 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:ObjectToPack

the object to write.

Exceptions
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.