FileDocCategorySizeDatePackage
Packet.javaAPI DocJ2ME CLDC 1.11968Wed Feb 05 15:56:04 GMT 2003kdp

Packet

public class Packet extends Object

Fields Summary
public static final short
NoFlags
public static final short
Reply
public static final short
ReplyNoError
static int
uID
static final byte[]
nullData
int
id
short
flags
short
cmdSet
short
cmd
short
errorCode
byte[]
data
volatile boolean
replied
int
curReadIndex
int
curWriteIndex
Constructors Summary
Packet()


    
    
        id = uniqID();
        flags = NoFlags;
        data = new byte[ 1024 ];
        curReadIndex = curWriteIndex = 0;
    
Methods Summary
public intgetLength()

        return curWriteIndex;
    
public voidsetData(byte[] d)

        data = new byte[ d.length ];
        System.arraycopy( d, 0, data, 0, data.length );
        curWriteIndex = data.length;
        curReadIndex = 0;
    
public java.lang.StringtoString()

        //return cmdSet+"/"+cmd+"/"+errorCode+"\n--->\n"+new String( data )+"\n<---\n";
    StringBuffer s = new StringBuffer();
        s.append(cmdSet).append("/").append(cmd).append("/").append(errorCode).append("\n--->\n");
    for (int i = 0; i < data.length; i++) {
        s.append(Integer.toHexString((int)((long)data[i] & 0xFF))).append(".");
    }
        s.append("\n<----\n");
    return s.toString();
    
private static synchronized intuniqID()

        /*
         * JDWP spec does not require this id to be sequential and
         * increasing, but our implementation does. See
         * VirtualMachine.notifySuspend, for example.
         */
        return uID++;