List of usage examples for javax.el ValueExpression getValue
public abstract Object getValue(ELContext context);
From source file:org.apache.shindig.expressions.OpensocialFunctionsTest.java
@Test public void testParseJsonNull() throws Exception { ValueExpression testUrlEncode = expressions.parse("${osx:parseJson(null)}", String.class); assertEquals("", testUrlEncode.getValue(context)); }
From source file:org.apache.shindig.expressions.OpensocialFunctionsTest.java
@Test public void testUrlEncodeNull() throws Exception { ValueExpression testUrlEncode = expressions.parse("${osx:urlEncode(null)}", String.class); assertEquals("", testUrlEncode.getValue(context)); }
From source file:org.apache.shindig.expressions.OpensocialFunctionsTest.java
@Test public void testUrlDecodeNull() throws Exception { ValueExpression testUrlDecode = expressions.parse("${osx:urlDecode(null)}", String.class); assertEquals("", testUrlDecode.getValue(context)); }
From source file:org.apache.shindig.expressions.OpensocialFunctionsTest.java
@Test public void testDecodeBase64Null() throws Exception { ValueExpression testUrlEncode = expressions.parse("${osx:decodeBase64(null)}", String.class); assertEquals("", testUrlEncode.getValue(context)); }
From source file:org.apache.shindig.expressions.OpensocialFunctionsTest.java
@Test public void testUrlEncode() throws Exception { String test = "He He"; vars.put("test", test); ValueExpression testUrlEncode = expressions.parse("${osx:urlEncode(test)}", String.class); assertEquals("He+He", testUrlEncode.getValue(context)); }
From source file:org.apache.shindig.expressions.OpensocialFunctionsTest.java
@Test public void testUrlDecode() throws Exception { String test = "He+He"; vars.put("encoded", test); ValueExpression testUrlDecode = expressions.parse("${osx:urlDecode(encoded)}", String.class); assertEquals("He He", testUrlDecode.getValue(context)); }
From source file:org.apache.shindig.expressions.OpensocialFunctionsTest.java
@Test public void testParseJsonObject() { ValueExpression testParseJsonObject = expressions.parse("${osx:parseJson('{a: 1}').a}", Integer.class); assertEquals(1, testParseJsonObject.getValue(context)); }
From source file:org.apache.shindig.expressions.OpensocialFunctionsTest.java
@Test public void testParseJsonArray() { ValueExpression testParseJsonArray = expressions.parse("${osx:parseJson('[1, 2, 3]')[1]}", Integer.class); assertEquals(2, testParseJsonArray.getValue(context)); }
From source file:org.apache.shindig.expressions.OpensocialFunctionsTest.java
@Test public void testDecodeBase64() throws Exception { String test = "12345"; String encoded = new String(Base64.encodeBase64(test.getBytes("UTF-8")), "UTF-8"); vars.put("encoded", encoded); ValueExpression testDecodeBase64 = expressions.parse("${osx:decodeBase64(encoded)}", String.class); assertEquals("12345", testDecodeBase64.getValue(context)); }
From source file:org.nuxeo.ecm.platform.actions.ELActionContext.java
@Override public boolean checkCondition(String expression) throws ELException { if (StringUtils.isBlank(expression) || (expression != null && StringUtils.isBlank(expression.trim()))) { return false; }/*from www . j a v a 2 s. c o m*/ String expr = expression.trim(); // compatibility code, as JEXL could resolve that kind of expression: // detect if expression is in brackets #{}, otherwise add it if (!expr.startsWith("#{") && !expr.startsWith("${") // don't confuse error messages in case of simple mistakes in the // expression && !expr.endsWith("}")) { expr = "#{" + expr + "}"; } VariableMapper vm = originalContext.getVariableMapper(); // init default variables ValueExpression documentExpr = expressionFactory.createValueExpression(getCurrentDocument(), DocumentModel.class); ValueExpression userExpr = expressionFactory.createValueExpression(getCurrentPrincipal(), NuxeoPrincipal.class); // add variables originally exposed by the action framework, // do not add aliases currentDocument and currentUser here as they // should already be available in this JSF context vm.setVariable("document", documentExpr); vm.setVariable("principal", userExpr); vm.setVariable("currentDocument", documentExpr); vm.setVariable("currentUser", userExpr); // get custom context from ActionContext for (String key : localVariables.keySet()) { vm.setVariable(key, expressionFactory.createValueExpression(getLocalVariable(key), Object.class)); } // evaluate expression ValueExpression ve = expressionFactory.createValueExpression(originalContext, expr, Boolean.class); return Boolean.TRUE.equals(ve.getValue(originalContext)); }