Top Description Fields Constructors Methods
org.eclipse.jgit.transport

public Class SideBandOutputStream

extends OutputStream
Class Inheritance
Imports
java.io.IOException, .OutputStream, java.text.MessageFormat, org.eclipse.jgit.internal.JGitText

Multiplexes data and progress messages.

This stream is buffered at packet sizes, so the caller doesn't need to wrap it in yet another buffered stream.

Since
2.0

Field Summary

Modifier and TypeField and Description
private final byte[]
public static final int
CH_DATA

Channel used for pack data.

public static final int
CH_ERROR

Channel used for error messages.

public static final int
CH_PROGRESS

Channel used for progress messages.

private int
cnt

Number of bytes in buffer that are valid data.

pack-priv static final int
public static final int
MAX_BUF

Maximum buffer size for a single packet of sideband data.

private final OutputStream
public static final int
SMALL_BUF

Default buffer size for a small amount of data.

Constructor Summary

AccessConstructor and Description
public
SideBandOutputStream(int
channel number to prefix all packets with, so the remote side can demultiplex the stream and get back the original data. Must be in the range [1, 255].
chan
,
int
maximum size of a data packet within the stream. The remote side needs to agree to the packet size to prevent buffer overflows. Must be in the range [HDR_SIZE + 1, MAX_BUF).
sz
,
OutputStream
stream that the packets are written onto. This stream should be attached to a SideBandInputStream on the remote side.
os
)

Create a new stream to write side band packets.

Method Summary

Modifier and TypeMethod and Description
public void
flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream and forces any buffered output bytes to be written out.

pack-priv void
public void
write(byte[]
the data.
b
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

public void
write(int
the byte.
b
)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

private void
Inherited from java.io.OutputStream:
closenullOutputStreamwrite

Field Detail

bufferback to summary
private final byte[] buffer
CH_DATAback to summary
public static final int CH_DATA

Channel used for pack data.

CH_ERRORback to summary
public static final int CH_ERROR

Channel used for error messages.

CH_PROGRESSback to summary
public static final int CH_PROGRESS

Channel used for progress messages.

cntback to summary
private int cnt

Number of bytes in buffer that are valid data.

Initialized to HDR_SIZE if there is no application data in the buffer, as the packet header always appears at the start of the buffer.

HDR_SIZEback to summary
pack-priv static final int HDR_SIZE
MAX_BUFback to summary
public static final int MAX_BUF

Maximum buffer size for a single packet of sideband data.

outback to summary
private final OutputStream out
SMALL_BUFback to summary
public static final int SMALL_BUF

Default buffer size for a small amount of data.

Constructor Detail

SideBandOutputStreamback to summary
public SideBandOutputStream(int chan, int sz, OutputStream os)

Create a new stream to write side band packets.

Parameters
chan:int

channel number to prefix all packets with, so the remote side can demultiplex the stream and get back the original data. Must be in the range [1, 255].

sz:int

maximum size of a data packet within the stream. The remote side needs to agree to the packet size to prevent buffer overflows. Must be in the range [HDR_SIZE + 1, MAX_BUF).

os:OutputStream

stream that the packets are written onto. This stream should be attached to a SideBandInputStream on the remote side.

Method Detail

flushback to summary
public void flush() throws IOException

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Doc from java.io.OutputStream.flush.

Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
flushBufferback to summary
pack-priv void flushBuffer() throws IOException
writeback to summary
public void write(byte[] b, int off, int len) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Parameters
b:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.
writeback to summary
public void write(int b) throws IOException

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
b:int

the byte.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
writeBufferback to summary
private void writeBuffer() throws IOException