public class PacketLineIn extends Object
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.
Modifier and Type | Class and Description |
---|---|
static class |
PacketLineIn.InputOverLimitIOException
IOException thrown by read when the configured input limit is exceeded.
|
static class |
PacketLineIn.PacketLineInIterator
Iterator over packet lines.
|
Modifier and Type | Field and Description |
---|---|
static String |
DELIM
Deprecated.
Callers should use
isDelimiter(String) to check if a
string is the delimiter. |
static String |
END
Deprecated.
Callers should use
isEnd(String) to check if a
string is the end marker, or
readStrings() to iterate over all
strings in the input stream until the marker is reached. |
Constructor and Description |
---|
PacketLineIn(InputStream in)
Create a new packet line reader.
|
PacketLineIn(InputStream in,
long limit)
Create a new packet line reader.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
isDelimiter(String s)
Check if a string is the delimiter marker.
|
static boolean |
isEnd(String s)
Check if a string is the packet end marker.
|
String |
readString()
Read a single UTF-8 encoded string packet from the input stream.
|
String |
readStringRaw()
Read a single UTF-8 encoded string packet from the input stream.
|
PacketLineIn.PacketLineInIterator |
readStrings()
Get an iterator to read strings from the input stream.
|
@Deprecated public static final String END
isEnd(String)
to check if a
string is the end marker, or
readStrings()
to iterate over all
strings in the input stream until the marker is reached.readString()
when a flush packet is found.@Deprecated public static final String DELIM
isDelimiter(String)
to check if a
string is the delimiter.readString()
when a delim packet is found.public PacketLineIn(InputStream in)
in
- the input stream to consume.public PacketLineIn(InputStream in, long limit)
in
- the input stream to consume.limit
- bytes to read from the input; unlimited if set to 0.public String readString() throws IOException
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.
END
if the string was the magic flush
packet, DELIM
if the string was the magic DELIM
packet.IOException
- the stream cannot be read.public PacketLineIn.PacketLineInIterator readStrings() throws IOException
readString()
until END
is encountered.IOException
- on failure to read the initial packet line.public String readStringRaw() throws IOException
Unlike readString()
a trailing LF will be retained.
END
if the string was the magic flush
packet.IOException
- the stream cannot be read.public static boolean isDelimiter(String s)
s
- the string to checkDELIM
, otherwise false.Copyright © 2021 Eclipse JGit Project. All rights reserved.