This class is not thread safe and may issue multiple writes to the underlying stream for each method call made.
This class performs no buffering on its own. This makes it suitable to interleave writes performed by this class with writes performed directly against the underlying OutputStream.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private static final byte[] | |
| private final byte[] | |
| private static final Logger | |
| private final boolean | |
| private final OutputStream | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | PacketLineOut(OutputStream
stream. outputStream, boolean false to suppress all logging; true to log
normallyCreate a new packet line writer that potentially doesn't log. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| private void | |
| pack-priv static void | |
| public boolean | Returns: whether to add a sideband designator to each non-flush and non-delim packetWhether is using sideband |
| public void | setFlushOnEnd(boolean
if true, a flush-pkt written during flushOnEnd)end() also
flushes the underlying stream.Set the flush behavior during |
| public void | setUsingSideband(boolean
If true, when writing packet lines, add, as the first byte, a
sideband designator to each non-flush and non-delim packet.
See pack-protocol.txt and protocol-v2.txt from the Git project
for more information, specifically the "side-band" and
"sideband-all" sections. value)Set whether to use sideband |
| public void | |
| public void | writePacket(byte[]
the packet to write; the length of the packet is equal to the
size of the byte array. packet)Write a binary packet to the stream. |
| public void | writePacket(byte[]
the packet to write buf, int first index within pos, int buf.number of bytes to write. len)Write a binary packet to the stream. |
| public void | writeString(String
string to write. s)Write a UTF-8 encoded string as a single length-delimited packet. |
| flushOnEnd | back to summary |
|---|---|
| private boolean flushOnEnd | |
| hexchar | back to summary |
|---|---|
| private static final byte[] hexchar | |
| lenbuffer | back to summary |
|---|---|
| private final byte[] lenbuffer | |
| log | back to summary |
|---|---|
| private static final Logger log | |
| logEnabled | back to summary |
|---|---|
| private final boolean logEnabled | |
| out | back to summary |
|---|---|
| private final OutputStream out | |
| usingSideband | back to summary |
|---|---|
| private boolean usingSideband | |
| PacketLineOut | back to summary |
|---|---|
| public PacketLineOut(OutputStream outputStream) Create a new packet line writer.
| |
| PacketLineOut | back to summary |
|---|---|
| public PacketLineOut(OutputStream outputStream, boolean enableLogging) Create a new packet line writer that potentially doesn't log.
| |
| end | back to summary |
|---|---|
| public void end() throws IOException Write a packet end marker, sometimes referred to as a flush command. Technically this is a magical packet type which can be detected separately from an empty string or an empty packet. Implicitly performs a flush on the underlying OutputStream to ensure the peer will receive all data written thus far.
| |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Flush the underlying OutputStream. Performs a flush on the underlying OutputStream to ensure the peer will receive all data written thus far.
| |
| formatLength | back to summary |
|---|---|
| private void formatLength(int w) | |
| formatLength | back to summary |
|---|---|
| pack-priv static void formatLength(byte[] lenbuffer, int w) | |
| isUsingSideband | back to summary |
|---|---|
| public boolean isUsingSideband() Whether is using sideband
| |
| setFlushOnEnd | back to summary |
|---|---|
| public void setFlushOnEnd(boolean flushOnEnd) Set the flush behavior during
| |
| setUsingSideband | back to summary |
|---|---|
| public void setUsingSideband(boolean value) Set whether to use sideband
| |
| writeDelim | back to summary |
|---|---|
| public void writeDelim() throws IOException Write a packet delim marker (0001).
| |
| writePacket | back to summary |
|---|---|
| public void writePacket(byte[] packet) throws IOException Write a binary packet to the stream.
| |
| writePacket | back to summary |
|---|---|
| public void writePacket(byte[] buf, int pos, int len) throws IOException Write a binary packet to the stream.
| |
| writeString | back to summary |
|---|---|
| public void writeString(String s) throws IOException Write a UTF-8 encoded string as a single length-delimited packet.
| |