/** * Hook method subclasses can override to return a specialized expression evaluating transition criteria * implementation. * @param encodedCriteria the encoded transition criteria expression * @param parser the parser that should parse the expression * @return the transition criteria object * @throws ConversionExecutionException when something goes wrong */ protected TransitionCriteria createBooleanExpressionTransitionCriteria(String encodedCriteria, ExpressionParser parser) throws ConversionExecutionException { Expression expression = parser.parseExpression(encodedCriteria, new FluentParserContext().template().evaluate(RequestContext.class)); return new DefaultTransitionCriteria(expression); } }
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception { String targetStateId = (String) source; if (!StringUtils.hasText(targetStateId)) { return null; } ExpressionParser parser = flowBuilderContext.getExpressionParser(); Expression expression = parser.parseExpression(targetStateId, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return new DefaultTargetStateResolver(expression); } }
private Action parseRenderAction(RenderModel render) { String[] fragmentExpressionStrings = StringUtils.commaDelimitedListToStringArray(render.getFragments()); fragmentExpressionStrings = StringUtils.trimArrayElements(fragmentExpressionStrings); ParserContext context = new FluentParserContext().template().evaluate(RequestContext.class) .expectResult(String.class); Expression[] fragments = new Expression[fragmentExpressionStrings.length]; for (int i = 0; i < fragmentExpressionStrings.length; i++) { String fragment = fragmentExpressionStrings[i]; fragments[i] = getLocalContext().getExpressionParser().parseExpression(fragment, context); } return new RenderAction(fragments); }
private ViewFactory parseViewFactory(String view, String stateId, boolean endState, BinderModel binderModel) { if (!StringUtils.hasText(view)) { if (endState) { return null; } else { view = getLocalContext().getViewFactoryCreator().getViewIdByConvention(stateId); Expression viewId = getLocalContext().getExpressionParser().parseExpression(view, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return createViewFactory(viewId, binderModel); } } else if (view.startsWith("externalRedirect:")) { String encodedUrl = view.substring("externalRedirect:".length()); Expression externalUrl = getLocalContext().getExpressionParser().parseExpression(encodedUrl, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return new ActionExecutingViewFactory(new ExternalRedirectAction(externalUrl)); } else if (view.startsWith("flowRedirect:")) { String flowRedirect = view.substring("flowRedirect:".length()); Expression expression = getLocalContext().getExpressionParser().parseExpression(flowRedirect, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return new ActionExecutingViewFactory(new FlowDefinitionRedirectAction(expression)); } else { Expression viewId = getLocalContext().getExpressionParser().parseExpression(view, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return createViewFactory(viewId, binderModel); } }
private Expression parseSubflowExpression(String subflow) { Expression subflowId = getLocalContext().getExpressionParser().parseExpression(subflow, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return new SubflowExpression(subflowId, getLocalContext().getFlowDefinitionLocator()); }
public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { String targetStateId = (String) source; if (!StringUtils.hasText(targetStateId)) { return null; } ExpressionParser parser = flowBuilderContext.getExpressionParser(); Expression expression = parser.parseExpression(targetStateId, new FluentParserContext().template().evaluate( RequestContext.class).expectResult(String.class)); return new DefaultTargetStateResolver(expression); } }
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception { String targetStateId = (String) source; if (!StringUtils.hasText(targetStateId)) { return null; } ExpressionParser parser = flowBuilderContext.getExpressionParser(); Expression expression = parser.parseExpression(targetStateId, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return new DefaultTargetStateResolver(expression); } }
private Action parseRenderAction(RenderModel render) { String[] fragmentExpressionStrings = StringUtils.commaDelimitedListToStringArray(render.getFragments()); fragmentExpressionStrings = StringUtils.trimArrayElements(fragmentExpressionStrings); ParserContext context = new FluentParserContext().template().evaluate(RequestContext.class) .expectResult(String.class); Expression[] fragments = new Expression[fragmentExpressionStrings.length]; for (int i = 0; i < fragmentExpressionStrings.length; i++) { String fragment = fragmentExpressionStrings[i]; fragments[i] = getLocalContext().getExpressionParser().parseExpression(fragment, context); } return new RenderAction(fragments); }
private Action parseRenderAction(RenderModel render) { String[] fragmentExpressionStrings = StringUtils.commaDelimitedListToStringArray(render.getFragments()); fragmentExpressionStrings = StringUtils.trimArrayElements(fragmentExpressionStrings); ParserContext context = new FluentParserContext().template().evaluate(RequestContext.class).expectResult( String.class); Expression[] fragments = new Expression[fragmentExpressionStrings.length]; for (int i = 0; i < fragmentExpressionStrings.length; i++) { String fragment = fragmentExpressionStrings[i]; fragments[i] = getLocalContext().getExpressionParser().parseExpression(fragment, context); } return new RenderAction(fragments); }
public void testTemplateEnclosedCompositeNotSupported() { String exp = "${hello ${flag} ${flag} ${flag}}"; try { parser.parseExpression(exp, new FluentParserContext().template()); fail("Should've failed - not intended use"); } catch (ParserException e) { } }
private Expression parseSubflowExpression(String subflow) { Expression subflowId = getLocalContext().getExpressionParser().parseExpression(subflow, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return new SubflowExpression(subflowId, getLocalContext().getFlowDefinitionLocator()); }
private Expression parseSubflowExpression(String subflow) { Expression subflowId = getLocalContext().getExpressionParser().parseExpression(subflow, new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return new SubflowExpression(subflowId, getLocalContext().getFlowDefinitionLocator()); }
public void testParseTemplateSimpleLiteral() { String exp = "flag"; Expression e = parser.parseExpression(exp, new FluentParserContext().template()); assertNotNull(e); assertEquals("flag", e.getValue(bean)); }
public void testParseTemplateComposite() { String exp = "hello ${flag} ${flag} ${flag}"; Expression e = parser.parseExpression(exp, new FluentParserContext().template()); assertNotNull(e); String str = (String) e.getValue(bean); assertEquals("hello false false false", str); }
public void testParseTemplateExpression() { String expressionString = "text text text #{value} text text text#{value}"; Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template()); TestBean target = new TestBean(); assertEquals("text text text foo text text textfoo", exp.getValue(target)); }
public void testParseTemplateExpression() { String expressionString = "text text text #{value} text text text#{value}"; Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template()); TestBean target = new TestBean(); assertEquals("text text text foo text text textfoo", exp.getValue(target)); }
public void testParseTemplateEmpty() { Expression e = parser.parseExpression("", new FluentParserContext().template()); assertNotNull(e); assertEquals("", e.getValue(bean)); }
public void testTemplateNestedVariables() { String expressionString = "#{value}#{max}"; Expression exp = parser.parseExpression( expressionString, new FluentParserContext().template().variable( new ExpressionVariable("max", "#{maximum}#{var}", new FluentParserContext().template() .variable(new ExpressionVariable("var", "'bar'"))))); TestBean target = new TestBean(); assertEquals("foo2bar", exp.getValue(target)); }
public void testParseTemplateExpressionWithVariables() { String expressionString = "#{value}#{max}"; Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template().variable(new ExpressionVariable("max", "maximum"))); TestBean target = new TestBean(); assertEquals("foo2", exp.getValue(target)); }
public void testParseTemplateExpressionWithVariables() { String expressionString = "#{value}#{#max}"; Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template().variable(new ExpressionVariable("max", "maximum"))); TestBean target = new TestBean(); assertEquals("foo2", exp.getValue(target)); // TODO: }