Package org.apache.harmony.dalvik.ddmc
Class ChunkHandler
- java.lang.Object
-
- org.apache.harmony.dalvik.ddmc.ChunkHandler
-
- Direct Known Subclasses:
DdmHandleAppName,DdmHandleExit,DdmHandleHeap,DdmHandleNativeHeap,DdmHandleProfiling,DdmHandleThread
public abstract class ChunkHandler extends Object
Handle a chunk of data sent from a DDM server. To handle a chunk type, sub-class ChunkHandler and register your class with DdmServer.
-
-
Field Summary
Fields Modifier and Type Field Description static intCHUNK_FAILstatic ByteOrderCHUNK_ORDER
-
Constructor Summary
Constructors Constructor Description ChunkHandler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidconnected()Called when the DDM server connects.static ChunkcreateFailChunk(int errorCode, String msg)Create a FAIL chunk.abstract voiddisconnected()Called when the DDM server disconnects.static StringgetString(ByteBuffer buf, int len)Utility function to copy a String out of a ByteBuffer.abstract ChunkhandleChunk(Chunk request)Handle a single chunk of data.static Stringname(int type)Convert an integer type to a 4-character string.static voidputString(ByteBuffer buf, String str)Utility function to copy a String into a ByteBuffer.static inttype(String typeName)Convert a 4-character string to a 32-bit type.static ByteBufferwrapChunk(Chunk request)Utility function to wrap a ByteBuffer around a Chunk.
-
-
-
Field Detail
-
CHUNK_ORDER
public static final ByteOrder CHUNK_ORDER
-
CHUNK_FAIL
public static final int CHUNK_FAIL
-
-
Method Detail
-
connected
public abstract void connected()
Called when the DDM server connects. The handler is allowed to send messages to the server.
-
disconnected
public abstract void disconnected()
Called when the DDM server disconnects. Can be used to disable periodic transmissions or clean up saved state.
-
handleChunk
public abstract Chunk handleChunk(Chunk request)
Handle a single chunk of data. "request" includes the type and the chunk payload. Returns a response in a Chunk.
-
createFailChunk
public static Chunk createFailChunk(int errorCode, String msg)
Create a FAIL chunk. The "handleChunk" methods can use this to return an error message when they are not able to process a chunk.
-
wrapChunk
public static ByteBuffer wrapChunk(Chunk request)
Utility function to wrap a ByteBuffer around a Chunk.
-
getString
public static String getString(ByteBuffer buf, int len)
Utility function to copy a String out of a ByteBuffer. This is here because multiple chunk handlers can make use of it, and there's nowhere better to put it.
-
putString
public static void putString(ByteBuffer buf, String str)
Utility function to copy a String into a ByteBuffer.
-
type
public static int type(String typeName)
Convert a 4-character string to a 32-bit type.
-
name
public static String name(int type)
Convert an integer type to a 4-character string.
-
-