FileDocCategorySizeDatePackage
Command.javaAPI DocphoneME MR2 API (J2ME)5093Wed May 02 17:59:48 BST 2007com.sun.cldchi.tools.memoryprofiler.jdwp

Command

public class Command extends Packet
This class encapsulates JDWP command. Its superclass is Packet so it's based on ByteBuffer. The class allows to set and get JDWP command number and automatically assign command ID. The typical use of Command class is as follows:
  • Create a new command object with specified command number
  • Fill command's data using standard ByteBuffer and Packet methods (for example, addInt() or addReferenceTypeID())
  • Execute command using BackEndTest.checkReplyF(), BackEndTest.sendCommand() or BackEndTest.checkReply()
  • Work with received Reply object if needed
see
jdwp.Packet
see
jdwp.ByteBuffer
see
jdwp.BackEndTest#checkReplyF(jdwp.Command)
see
jdwp.BackEndTest#sendCommand(jdwp.Command)
see
jdwp.BackEndTest#checkReply(jdwp.Command)
see
jdwp.Reply

Fields Summary
private static int
nextID
ID of next command. Each JDWP command must have unique ID. The simplest way (that is used here) for generating these IDs is a incremental counter. So this variable is incremented after creating of each command and contains ID of next command.
Constructors Summary
public Command(int command)
Creates a new Command object, assign an unique ID, the specified command number and sets flags to flNoFlags. Command number is two-byte integer where hi-order byte specifies the JDWP command set and low-order byte specifies the command number in the command set. For example, ArrayReference/GetValues JDWP command has a number 0x0D02 where 0x0D = 14 is a number of ArrayReference command set and 0x02 is a number of GetValues command in this command set. For information about numbers of specific commands and command sets see JDWP specification.

param
command a command number for this command


                                                                                                        
       
	super();
	setID(nextID++);
	setFlags(flNoFlags);
	setCommand(command);
    
Methods Summary
public intgetCommand()
Gets number of the command assigned for this object. For information about command numbers see description of the constructor. I suspect this method is not used currently by KJDB

return
a command number

        int id = 0;

	try {
            id = (int) getID(CommandOffset, 2);
	}
	catch (BoundException e) {};
	return id;
    
public static intgetLastID()
Returns the ID of the command last created. I think that this method is not used currently by KJDB.

return
ID of last command

    	return (nextID - 1);
    
public voidsetCommand(int command)
Assign a command number to the object. For information about command numbers see description of the constructor. This method is used internally by constructor.

param
command a command number to be assigned

	try {
            putID(CommandOffset, command, 2);
	}
	catch (BoundException e) {};
    
public java.lang.StringtoString()
Returns string representation of the object. This method is invoked when reply packet of the command is not received (usually it's a fatal error). It's useful for locating the problem.

return
a string representation of the object

        
    	int l = 0;
        try {
            l = getInt(LengthOffset);
        }
        catch (BoundException e) {};

	return "length     " + Tools.Hex(l, 8) + "\n" +
            "id         " + Tools.Hex(getID(), 8) + "\n" +
            "flags      " + Tools.Hex(getFlags(), 2) + "\n" +
            "command    " + Tools.Hex(getCommand(), 4) + "\n" +
            super.toString(PacketHeaderSize);