com.android.ddmlib
Class MultiLineReceiver

java.lang.Object
  extended by com.android.ddmlib.MultiLineReceiver
All Implemented Interfaces:
IShellOutputReceiver
Direct Known Subclasses:
InstrumentationResultParser

public abstract class MultiLineReceiver
extends Object
implements IShellOutputReceiver

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.


Constructor Summary
MultiLineReceiver()
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.android.ddmlib.IShellOutputReceiver
isCancelled
 

Constructor Detail

MultiLineReceiver

public MultiLineReceiver()
Method Detail

setTrimLine

public void setTrimLine(boolean trim)
Set the trim lines flag.

Parameters:
trim - hether the lines are trimmed, or not.

addOutput

public final void addOutput(byte[] data,
                            int offset,
                            int length)
Description copied from interface: IShellOutputReceiver
Called every time some new data is available.

Specified by:
addOutput in interface IShellOutputReceiver
Parameters:
data - The new data.
offset - The offset at which the new data starts.
length - The length of the new data.

flush

public final void flush()
Description copied from interface: IShellOutputReceiver
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.

Specified by:
flush in interface IShellOutputReceiver

done

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


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 - The array containing the new lines.


Copyright © 2008-2012. All Rights Reserved.