Skip Navigation

Sample Code for an Emulator Request and Response

The following code sample gets a markup request and response, and includes markup instructions.

ContextStatusAdvisor contextAdvisor = new ContextStatusAdvisor(context,getClass());

IRequest request = context.getRequest();
if (request instanceof EmulatorMarkupRequest)
{
EmulatorMarkupRequest markupRequest = (EmulatorMarkupRequest) context.getRequest();

//Markup instructions go here
Map<String, String> markupInstructions = new HashMap<String, String>();
markupInstructions.put("api.modify", "true");
markupInstructions.put("api.modify.count", "1");
markupInstructions.put("api.modify.0", "apiInsert");
markupInstructions.put("api.modify.0.type", "line.insert");
markupInstructions.put("api.modify.0.before", "1");
markupInstructions.put("apiInsert.item.count", "1");
markupInstructions.put("apiInsert.item.0", "This line was inserted by MarkupService");

EmulatorMarkupResponse response = new EmulatorMarkupResponse(markupInstructions);
contextAdvisor.success(response);
}
else
{
String errorCode = ErrorCodeFormatter.getInstance("BRIDGE001").format(1);
String[] paramaters = { context.getRequestorId(), context.getContextName() };

IError error = contextAdvisor.error(errorCode, paramaters);
}