MultiLineReceiver

public abstract class MultiLineReceiver
extends Object implements IShellOutputReceiver

java.lang.Object
   ↳ com.android.ddmlib.MultiLineReceiver


Base implementation of IShellOutputReceiver, that takes the raw data coming from the socket, and convert it into String objects.

Additionally, it splits the string by lines.

Classes extending it must implement processNewLines(String[]) which receives new parsed lines as they become available.

Summary

Public constructors

MultiLineReceiver()

Public methods

final void addOutput(byte[] data, int offset, int length)

Called every time some new data is available.

void done()

Terminates the process.

void flush()

Called at the end of the process execution (unless the process was canceled).

abstract void processNewLines(String[] lines)

Called when new lines are being received by the remote process.

void setTrimLine(boolean trim)

Set the trim lines flag.

Public constructors

MultiLineReceiver

public MultiLineReceiver ()

Public methods

addOutput

public final void addOutput (byte[] data, 
                int offset, 
                int length)

Called every time some new data is available.

Parameters
data byte: The new data.

offset int: The offset at which the new data starts.

length int: The length of the new data.

done

public void done ()

Terminates the process. This is called after the last lines have been through processNewLines(String[]).

flush

public void flush ()

Called at the end of the process execution (unless the process was canceled). This allows the receiver to terminate and flush whatever data was not yet processed.

processNewLines

public abstract void processNewLines (String[] lines)

Called when new lines are being received by the remote process.

It is guaranteed that the lines are complete when they are given to this method.

Parameters
lines String: The array containing the new lines.

setTrimLine

public void setTrimLine (boolean trim)

Set the trim lines flag.

Parameters
trim boolean: whether the lines are trimmed, or not.