org.eclipse.jgit.transport
Class PacketLineIn

java.lang.Object
  extended by org.eclipse.jgit.transport.PacketLineIn

public class PacketLineIn
extends Object

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.


Field Summary
static String END
          Magic return from readString() when a flush packet is found.
 
Constructor Summary
PacketLineIn(InputStream i)
          Create a new packet line reader.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

END

public static final String END
Magic return from readString() when a flush packet is found.

Constructor Detail

PacketLineIn

public PacketLineIn(InputStream i)
Create a new packet line reader.

Parameters:
i - the input stream to consume.
Method Detail

readString

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:
the string. END if the string was the magic flush packet.
Throws:
IOException - the stream cannot be read.

readStringRaw

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:
the string. END if the string was the magic flush packet.
Throws:
IOException - the stream cannot be read.


Copyright © 2012. All Rights Reserved.