Fields Summary |
---|
public static final int | flNoFlagsJDWP packet flag "no flags". Indicates that the packet is a command. |
public static final int | flReplyJDWP packet flag Reply . Indicates that the packet is a
reply. |
public static final int | LengthOffsetOffset of the "packet length" field in the JDWP packet. |
public static final int | IdOffsetOffset of the "packet ID" field in the JDWP packet. |
public static final int | FlagsOffsetOffset of the "flags" field in the JDWP packet. |
public static final int | CommandOffsetOffset of the "command number" field in the JDWP packet. |
public static final int | ErrorCodeOffsetOffset of the "error code" field in the JDWP packet. |
public static final int | PacketHeaderSizeSize of JDWP packet's header. |
Methods Summary |
---|
public void | addFieldID(long b)Adds a field ID to the end of JDWP packet.
addID(b, jdwp.fieldIDSize);
|
public void | addFrameID(long b)Adds a frame ID to the end of JDWP packet.
addID(b, jdwp.frameIDSize);
|
public void | addMethodID(long b)Adds a method ID to the end of JDWP packet.
addID(b, jdwp.methodIDSize);
|
public void | addObjectID(long b)Adds an object ID to the end of JDWP packet.
addID(b, jdwp.objectIDSize);
|
public void | addReferenceTypeID(long b)Adds a reference type ID to the end of JDWP packet.
addID(b, jdwp.referenceTypeIDSize);
|
private void | doParse(java.lang.String how, java.util.Vector v)Performs the parsing of the JDWP oacket in fact. The all the
parsing rules that described in the description of
parse method are the same besides of absence of
'.' symbol in the mask.
int index = 0;
char[] h = how.toCharArray();
while (index < h.length) {
switch (h[index]) {
case 'b":
v.add(new Integer(getByte()));
break;
case 'i":
v.add(new Integer(getInt()));
break;
case 'S":
v.add(new Integer(getShort()));
break;
case 'l":
v.add(new Long(getLong()));
break;
case 's":
v.add(getString());
break;
case 'f":
v.add(new Long(getFieldID()));
break;
case 'm":
v.add(new Long(getMethodID()));
break;
case 'o":
v.add(new Long(getObjectID()));
break;
case 'r":
v.add(new Long(getReferenceTypeID()));
break;
case 'F":
v.add(new Long(getFrameID()));
break;
case 'v":
int vtype = getByte();
v.add(new Integer(vtype));
switch (vtype) {
case jdwp.tagARRAY:
case jdwp.tagOBJECT:
v.add(new Long(getObjectID()));
break;
case jdwp.tagBYTE:
v.add(new Integer(getByte()));
break;
case jdwp.tagINT:
v.add(new Integer(getInt()));
break;
case jdwp.tagSHORT:
v.add(new Integer(getShort()));
break;
case jdwp.tagVOID:
v.add("void value");
break;
case jdwp.tagBOOLEAN:
v.add(new Integer(getByte()));
break;
case jdwp.tagLONG:
v.add(new Long(getLong()));
break;
default:
throw new BoundException();
}
break;
case '(":
if (index == 0)
throw new BoundException();
if (h[index - 1] != 'i")
throw new BoundException();
int n = ((Integer) v.elementAt(v.size() - 1)).intValue();
if (n < 0)
throw new BoundException();
int pos = index + 1;
int cnt = 1;
int last = -1;
while (pos < h.length) {
if (h[pos] == '(")
cnt++;
if (h[pos] == ')") {
cnt--;
if (cnt == 0) {
last = pos;
break;
}
}
pos++;
}
if (last == -1)
throw new BoundException();
String s = new String(h, index + 1, last - index - 1);
for (int i = 0; i < n; i++)
doParse(s, v);
index = last;
break;
default:
throw new BoundException();
}
index++;
}
|
public int | getDataSize()Returns size of packet's data (i.e., size of the packet
excluding header).
return length() - PacketHeaderSize;
|
public long | getFieldID()Tries to read next field ID from the buffer.
Value is read is one
that is pointed by reading marker. After completing the operation
the reading marker is incremented.
return getID(jdwp.fieldIDSize);
|
public int | getFlags()Returns flags of the JDWP packet.
return bytes[FlagsOffset] & 0xff;
|
public long | getFrameID()Tries to read next frame ID from the buffer.
Value is read is one
that is pointed by reading marker. After completing the operation
the reading marker is incremented.
return getID(jdwp.frameIDSize);
|
public int | getID()Returns ID of the JDWP packet.
int id = 0;
try {
id = getInt(IdOffset);
}
catch (BoundException e) {};
return id;
|
public long | getMethodID()Tries to read next method ID from the buffer.
Value is read is one
that is pointed by reading marker. After completing the operation
the reading marker is incremented.
return getID(jdwp.methodIDSize);
|
public long | getObjectID()Tries to read next object ID from the buffer.
Value is read is one
that is pointed by reading marker. After completing the operation
the reading marker is incremented.
return getID(jdwp.objectIDSize);
|
public long | getReferenceTypeID()Tries to read next reference type ID from the buffer.
Value is read is one
that is pointed by reading marker. After completing the operation
the reading marker is incremented.
return getID(jdwp.referenceTypeIDSize);
|
public java.util.Vector | parse(java.lang.String how)Parses the JDWP packet according to the specified mask. The mask
specifies what elements are contained in JDWP packet's data. The rules
are as follows:
- b - a byte value
- i - an int value
- S - a short value
- l - a long value
- s - a string value
- f - a field ID
- m - a method ID
- o - an object ID
- r - a reference type ID
- F - a frame ID
- v - a value. The first byte indicates type tag of the
variable, the second is a variable's value.
- . - a set of data in the end of packet that should not be parsed.
- i(<submask>) - the first integer indicates how many times
submask is appeared in the packet.
For example, the mask li(rm) means that the first element
of packet's data is a long value, then an int
value that indicates how many times the pair "reference type ID -
method ID" is appeared later.
boolean check;
check = (how.indexOf('.") == -1);
if (! check) {
if (how.indexOf('.") != how.length() - 1)
throw new BoundException();
how = Tools.Left(how, how.length() - 1);
}
Vector v = new Vector();
resetDataParser();
doParse(how, v);
if (check && (! isParsed()))
throw new BoundException();
return v;
|
public void | resetDataParser()Moves the reading marker to the beginning of packet data
(after the header). To learn about reading marker see
ByteBuffer .
resetParser(PacketHeaderSize);
|
public void | setFlags(int Flags)Sets flags of the JDWP packet.
bytes[FlagsOffset] = (byte) (Flags & 0xFF);
|
public void | setID(int Id)Sets ID of the JDWP packet.
try {
putInt(IdOffset, Id);
}
catch (BoundException e) {};
|
public void | setLength()Sets "packet length" field of the JDWP packet
try {
putInt(LengthOffset, length());
}
catch (BoundException e) {};
|