XmlExtensionNotificationDataConverter implements ExtensionNotificationDataConverter { @Override public Object convertApplicationLastResult( final List<LastResult> lastresults) throws ConversionException { if (lastresults == null || lastresults.isEmpty()) { return null; } final LastResult lastresult = lastresults.get(0); final String utterance = lastresult.getUtterance(); final String mode = lastresult.getInputmode(); final float confidence = lastresult.getConfidence(); final Object interpretation = lastresult.getInterpretation(); try { return createEmma("lastresult", utterance, mode, confidence, interpretation); } catch (ParserConfigurationException e) { throw new ConversionException(e.getMessage(), e); } }  @Override Object convertApplicationLastResult(
            final List<LastResult> lastresults); @Override Object convertSynthesizedOutputEvent(SynthesizedOutputEvent output); @Override Object convertSpokenInputEvent(final SpokenInputEvent input); @Override Object convertRecognitionEvent(final DataModel model,
            final RecognitionEvent event); static final String JVXML_MMI_NAMESPACE; }
@Test public void testConvertApplicationLastResult() throws Exception { final XmlExtensionNotificationDataConverter converter = new XmlExtensionNotificationDataConverter(); final List<LastResult> list = new java.util.ArrayList<LastResult>(); final LastResult result = new LastResult("yes", .75f, "voice", null); list.add(result); final Element element = (Element) converter.convertApplicationLastResult(list); System.out.println(toString(element)); }
@Test public void testConvertApplicationLastResultSimpleSemanticInterpretation() throws Exception { final XmlExtensionNotificationDataConverter converter = new XmlExtensionNotificationDataConverter(); final List<LastResult> list = new java.util.ArrayList<LastResult>(); final Context context = Context.enter(); context.setLanguageVersion(Context.VERSION_1_6); final Scriptable scope = context.initStandardObjects(); context.evaluateString(scope, "var out = 'yes';", "expr", 1, null); final Object out = scope.get("out", scope); final LastResult result = new LastResult("yeah", .75f, "voice", out); list.add(result); Element element = (Element) converter.convertApplicationLastResult(list); System.out.println(toString(element)); }
@Test public void testConvertApplicationLastResultComplexSemanticInterpretation() throws Exception { final XmlExtensionNotificationDataConverter converter = new XmlExtensionNotificationDataConverter(); final List<LastResult> list = new java.util.ArrayList<LastResult>(); final Context context = Context.enter(); context.setLanguageVersion(Context.VERSION_1_6); final Scriptable scope = context.initStandardObjects(); context.evaluateString(scope, "var out = new Object();", "expr", 1, null); context.evaluateString(scope, "var out = new Object();", "expr", 1, null); context.evaluateString(scope, "out.order = new Object();", "expr", 1, null); context.evaluateString(scope, "out.order.topping = 'Salami';", "expr", 1, null); context.evaluateString(scope, "out.order.size = 'medium';", "expr", 1, null); context.evaluateString(scope, "out.date = 'now';", "expr", 1, null); final Object out = scope.get("out", scope); final LastResult result = new LastResult("yes", .75f, "voice", out); list.add(result); final Element element = (Element) converter .convertApplicationLastResult(list); System.out.println(toString(element)); }