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

public Class PacketLineIn

extends Object
Class Inheritance
Static Imports
java.nio.charset.StandardCharsets.UTF_8

Read Git style pkt-line formatting from an input stream.

This class is not thread safe and may issue multiple reads to the underlying stream for each method call made.

This class performs no buffering on its own. This makes it suitable to interleave reads performed by this class with reads performed directly against the underlying InputStream.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum
public static class
PacketLineIn.InputOverLimitIOException

IOException thrown by read when the configured input limit is exceeded.

public static class
PacketLineIn.PacketLineInIterator

Iterator over packet lines.

Field Summary

Modifier and TypeField and Description
private static final String
DELIM

Magic return from readString() when a delim packet is found.

private static final String
END

Magic return from readString() when a flush packet is found.

private final InputStream
private long
private final byte[]
private static final Logger

Constructor Summary

AccessConstructor and Description
public
PacketLineIn(InputStream
the input stream to consume.
in
)

Create a new packet line reader.

public
PacketLineIn(InputStream
the input stream to consume.
in
,
long
bytes to read from the input; unlimited if set to 0.
limit
)

Create a new packet line reader.

Method Summary

Modifier and TypeMethod and Description
pack-priv static String

Returns:

The delimiter marker.
delimiter
()

Get the delimiter marker.

pack-priv void
pack-priv static String

Returns:

The end marker.
end
()

Get the end marker.

private IOException
private IOException
public static boolean

Returns:

true if the given string is DELIM, otherwise false.
isDelimiter
(String
the string to check
s
)

Check if a string is the delimiter marker.

public static boolean

Returns:

true if the given string is END, otherwise false.
isEnd
(String
the string to check
s
)

Check if a string is the packet end marker.

pack-priv static PacketLineIn.AckNackResult

Returns:

one of NAK, ACK_COMMON, or ACK_READY
parseACKv2
(String
to parse
line
,
MutableObjectId
in case of ACK_COMMON
returnedId
)

Parses a ACK/NAK line in protocol V2.

pack-priv PacketLineIn.AckNackResult
pack-priv int
public String

Returns:

the string. END if the string was the magic flush packet, DELIM if the string was the magic DELIM packet.
readString
()

Read a single UTF-8 encoded string packet from the input stream.

public String

Returns:

the string. END if the string was the magic flush packet.
readStringRaw
()

Read a single UTF-8 encoded string packet from the input stream.

public PacketLineIn.PacketLineInIterator

Returns:

an iterator that calls readString() until END is encountered.
readStrings
()

Get an iterator to read strings from the input stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DELIMback to summary
private static final String DELIM

Magic return from readString() when a delim packet is found.

ENDback to summary
private static final String END

Magic return from readString() when a flush packet is found.

inback to summary
private final InputStream in
limitback to summary
private long limit
lineBufferback to summary
private final byte[] lineBuffer
logback to summary
private static final Logger log

Constructor Detail

PacketLineInback to summary
public PacketLineIn(InputStream in)

Create a new packet line reader.

Parameters
in:InputStream

the input stream to consume.

PacketLineInback to summary
public PacketLineIn(InputStream in, long limit)

Create a new packet line reader.

Parameters
in:InputStream

the input stream to consume.

limit:long

bytes to read from the input; unlimited if set to 0.

Since
4.7

Method Detail

delimiterback to summary
pack-priv static String delimiter()

Get the delimiter marker.

Intended for use only in tests.

Returns:String

The delimiter marker.

discardUntilEndback to summary
pack-priv void discardUntilEnd() throws IOException
endback to summary
pack-priv static String end()

Get the end marker.

Intended for use only in tests.

Returns:String

The end marker.

invalidHeaderback to summary
private IOException invalidHeader()
invalidHeaderback to summary
private IOException invalidHeader(Throwable cause)
isDelimiterback to summary
public static boolean isDelimiter(String s)

Check if a string is the delimiter marker.

Parameters
s:String

the string to check

Returns:boolean

true if the given string is DELIM, otherwise false.

Annotations
@SuppressWarnings:ReferenceEquality, StringEquality
Since
5.4
isEndback to summary
public static boolean isEnd(String s)

Check if a string is the packet end marker.

Parameters
s:String

the string to check

Returns:boolean

true if the given string is END, otherwise false.

Annotations
@SuppressWarnings:ReferenceEquality, StringEquality
Since
5.4
parseACKv2back to summary
pack-priv static PacketLineIn.AckNackResult parseACKv2(String line, MutableObjectId returnedId) throws IOException

Parses a ACK/NAK line in protocol V2.

Parameters
line:String

to parse

returnedId:MutableObjectId

in case of ACK_COMMON

Returns:PacketLineIn.AckNackResult

one of NAK, ACK_COMMON, or ACK_READY

Exceptions
IOException:
on protocol or transport errors
readACKback to summary
pack-priv PacketLineIn.AckNackResult readACK(MutableObjectId returnedId) throws IOException
readLengthback to summary
pack-priv int readLength() throws IOException
readStringback to summary
public String readString() throws IOException

Read a single UTF-8 encoded string packet from the input stream.

If the string ends with an LF, it will be removed before returning the value to the caller. If this automatic trimming behavior is not desired, use readStringRaw() instead.

Returns:String

the string. END if the string was the magic flush packet, DELIM if the string was the magic DELIM packet.

Exceptions
IOException:
the stream cannot be read.
readStringRawback to summary
public String readStringRaw() throws IOException

Read a single UTF-8 encoded string packet from the input stream.

Unlike readString() a trailing LF will be retained.

Returns:String

the string. END if the string was the magic flush packet.

Exceptions
IOException:
the stream cannot be read.
readStringsback to summary
public PacketLineIn.PacketLineInIterator readStrings() throws IOException

Get an iterator to read strings from the input stream.

Returns:PacketLineIn.PacketLineInIterator

an iterator that calls readString() until END is encountered.

Exceptions
IOException:
on failure to read the initial packet line.
Since
5.4
org.eclipse.jgit.transport back to summary

pack-priv final Enum PacketLineIn.AckNackResult

extends Enum<PacketLineIn.AckNackResult>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final PacketLineIn.AckNackResult
ACK

ACK

public static final PacketLineIn.AckNackResult
ACK_COMMON

ACK + common

public static final PacketLineIn.AckNackResult
ACK_CONTINUE

ACK + continue

public static final PacketLineIn.AckNackResult
ACK_READY

ACK + ready

public static final PacketLineIn.AckNackResult
NAK

NAK

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static PacketLineIn.AckNackResult
public static PacketLineIn.AckNackResult[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ACKback to summary
public static final PacketLineIn.AckNackResult ACK

ACK

ACK_COMMONback to summary
public static final PacketLineIn.AckNackResult ACK_COMMON

ACK + common

ACK_CONTINUEback to summary
public static final PacketLineIn.AckNackResult ACK_CONTINUE

ACK + continue

ACK_READYback to summary
public static final PacketLineIn.AckNackResult ACK_READY

ACK + ready

NAKback to summary
public static final PacketLineIn.AckNackResult NAK

NAK

Constructor Detail

AckNackResultback to summary
private AckNackResult()

Method Detail

valueOfback to summary
public static PacketLineIn.AckNackResult valueOf(String name)
valuesback to summary
public static PacketLineIn.AckNackResult[] values()
org.eclipse.jgit.transport back to summary

public Class PacketLineIn.InputOverLimitIOException

extends IOException
Class Inheritance

IOException thrown by read when the configured input limit is exceeded.
Since
4.7

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.io.IOException.serialVersionUID.

Constructor Detail

InputOverLimitIOExceptionback to summary
public InputOverLimitIOException()
org.eclipse.jgit.transport back to summary

public Class PacketLineIn.PacketLineInIterator

extends Object
implements Iterable<String>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable

Iterator over packet lines.

Calls readString() on the PacketLineIn until END is encountered.

Since
5.4

Field Summary

Modifier and TypeField and Description
private String
private PacketLineIn

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Iterator<String>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private String current
inback to summary
private PacketLineIn in

Constructor Detail

PacketLineInIteratorback to summary
pack-priv PacketLineInIterator(PacketLineIn in) throws IOException

Method Detail

iteratorback to summary
public Iterator<String> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<String>

an Iterator.

Annotations
@Override