* event to set request for
* @return ReplyPacket for setting request
*/
public ReplyPacket setEvent(Event event) {
// Create new command packet
CommandPacket commandPacket = new CommandPacket(
JDWPCommands.EventRequestCommandSet.CommandSetID,
JDWPCommands.EventRequestCommandSet.SetCommand);
// Set eventKind
commandPacket.setNextValueAsByte(event.eventKind);
// Set suspendPolicy
commandPacket.setNextValueAsByte(event.suspendPolicy);
// Set modifiers
commandPacket.setNextValueAsInt(event.modifiers);
for (int i = 0; i < event.modifiers; i++) {
commandPacket.setNextValueAsByte(event.mods[i].modKind);
switch (event.mods[i].modKind) {
case EventMod.ModKind.Count: {
// Case Count
commandPacket.setNextValueAsInt(event.mods[i].count);
break;
}
case EventMod.ModKind.Conditional: {
// Case Conditional
commandPacket.setNextValueAsInt(event.mods[i].exprID);
break;
}
case EventMod.ModKind.ThreadOnly: {
// Case ThreadOnly
commandPacket.setNextValueAsThreadID(event.mods[i].thread);
break;
}
case EventMod.ModKind.ClassOnly: {
// Case ClassOnly
commandPacket
.setNextValueAsReferenceTypeID(event.mods[i].clazz);
break;
}
case EventMod.ModKind.ClassMatch: {
// Case ClassMatch
commandPacket.setNextValueAsString(event.mods[i].classPattern);
break;
}
case EventMod.ModKind.ClassExclude: {
// Case ClassExclude
commandPacket.setNextValueAsString(event.mods[i].classPattern);
break;
}
case EventMod.ModKind.LocationOnly: {
// Case LocationOnly
commandPacket.setNextValueAsLocation(event.mods[i].loc);
break;
}
case EventMod.ModKind.ExceptionOnly:
// Case ExceptionOnly
commandPacket
.setNextValueAsReferenceTypeID(event.mods[i].exceptionOrNull);
commandPacket.setNextValueAsBoolean(event.mods[i].caught);
commandPacket.setNextValueAsBoolean(event.mods[i].uncaught);
break;
case EventMod.ModKind.FieldOnly: {
// Case FieldOnly
commandPacket
.setNextValueAsReferenceTypeID(event.mods[i].declaring);
commandPacket.setNextValueAsFieldID(event.mods[i].fieldID);
break;
}
case EventMod.ModKind.Step: {
// Case Step
commandPacket.setNextValueAsThreadID(event.mods[i].thread);
commandPacket.setNextValueAsInt(event.mods[i].size);
commandPacket.setNextValueAsInt(event.mods[i].depth);
break;
}
case EventMod.ModKind.InstanceOnly: {
// Case InstanceOnly
commandPacket.setNextValueAsObjectID(event.mods[i].instance);
break;
}
}
}