org.eclipse.jgit.storage.pack
Class PackOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.eclipse.jgit.storage.pack.PackOutputStream
All Implemented Interfaces:
Closeable, Flushable

public final class PackOutputStream
extends OutputStream

Custom output stream to support PackWriter.


Constructor Summary
PackOutputStream(ProgressMonitor writeMonitor, OutputStream out, PackWriter pw)
          Initialize a pack output stream.
 
Method Summary
 void flush()
           
 byte[] getCopyBuffer()
           
 long length()
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 void writeHeader(ObjectToPack otp, long rawLength)
          Commits the object header onto the stream.
 void writeObject(ObjectToPack otp)
          Write one object.
 
Methods inherited from class java.io.OutputStream
close, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackOutputStream

public PackOutputStream(ProgressMonitor writeMonitor,
                        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 void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

writeObject

public 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 - the object to write.
Throws:
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 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 - 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:
IOException - the underlying stream refused to accept the header.

getCopyBuffer

public byte[] getCopyBuffer()
Returns:
a temporary buffer writers can use to copy data with.

length

public long length()
Returns:
total number of bytes written since stream start.


Copyright © 2012. All Rights Reserved.