/** * {@inheritDoc} * * <p>Retrieves all attributes of the current tag and store their values in the attributes map. If * there is no value in the prompt, the method tries to find a value that has been set via a * <code><property></code> tag.<br> * Implementations are requested to obtain the values via the {@link #getAttribute(String)} * method. */ @Override public void getAttributes( final VoiceXmlInterpreterContext context, final FormInterpretationAlgorithm fia, final VoiceXmlNode node) { if (node == null) { LOGGER.warn("cannot get attributes from null"); } attributes.clear(); // Check all possible attributes, if it is defined // 1. in the node // 2. as a property. final Collection<String> names = node.getAttributeNames(); for (String name : names) { String value = node.getAttribute(name); if (value == null) { value = context.getProperty(name); } if (value != null) { attributes.put(name, value); } } }
/** * Set up the test environment. * * @since 0.7.6 */ @Before public void setUp() { final SsmlParsingStrategyFactory factory = Mockito.mock(SsmlParsingStrategyFactory.class); Mockito.when(factory.getParsingStrategy(Mockito.isA(Value.class))) .thenReturn(new ValueStrategy()); final VoiceXmlInterpreterContext context = getContext(); final Profile profile = context.getProfile(); Mockito.when(profile.getSsmlParsingStrategyFactory()).thenReturn(factory); Mockito.when(profile.getSsmlParsingStrategyFactory()).thenReturn(factory); final TagStrategyFactory tagfactory = Mockito.mock(TagStrategyFactory.class); Mockito.when(tagfactory.getTagStrategy(Mockito.isA(Value.class))) .thenReturn(new ValueStrategy()); Mockito.when(tagfactory.getTagStrategy(Mockito.isA(Text.class))).thenReturn(new TextStrategy()); Mockito.when(profile.getTagStrategyFactory()).thenReturn(tagfactory); final ImplementationPlatform platform = Mockito.mock(ImplementationPlatform.class); Mockito.when(context.getImplementationPlatform()).thenReturn(platform); }
/** {@inheritDoc} */ @Override public void evalAttributes(final VoiceXmlInterpreterContext context) throws SemanticError { final DataModel model = context.getDataModel(); final Collection<String> evalAttributes = getEvalAttributes(); if (evalAttributes == null) { return; } // Actually evalute the attributes for (String name : evalAttributes) { final Object expr = attributes.get(name); if (expr != null) { final String exprstring = expr.toString(); final String unescapedExprstring = StringEscapeUtils.unescapeXml(exprstring); Object value = model.evaluateExpression(unescapedExprstring, Object.class); attributes.put(name, value); } } }
/** {@inheritDoc} */ public void execute( final VoiceXmlInterpreterContext context, final VoiceXmlInterpreter interpreter, final FormInterpretationAlgorithm fia, final FormItem item, final VoiceXmlNode node) throws JVoiceXMLEvent { if (nextItem != null) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("going to item '" + nextItem + "'..."); } throw new GotoNextFormItemEvent(nextItem); } if (next.startsWith("#")) { final String nextForm = next.substring(1); if (LOGGER.isDebugEnabled()) { LOGGER.debug("going to form '" + nextForm + "'..."); } throw new GotoNextFormEvent(nextForm); } else { final URI uri; try { uri = new URI(next); } catch (java.net.URISyntaxException use) { throw new BadFetchError(use); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("going to uri '" + uri + "'..."); } final DocumentDescriptor descriptor = new DocumentDescriptor(uri); final FetchAttributes attributes = getFetchAttributes(); descriptor.setAttributes(attributes); final VoiceXmlDocument document = context.loadDocument(descriptor); final URI resolvedUri = descriptor.getUri(); throw new GotoNextDocumentEvent(resolvedUri, document); } }