protected Expression createXPathTextExpression(String exprText) throws JellyException { return CompositeExpression.parse( exprText, this.jexlFactory ); } }
protected void configureStaticTagAttributes(TagScript script, Attributes list) throws JellyException { // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeValue = list.getValue(i); Expression expression = CompositeExpression.parse( attributeValue, getExpressionFactory() ); String attrQName = list.getQName(i); int p = attrQName.indexOf(':'); String prefix = p>=0 ? attrQName.substring(0,p): ""; script.addAttribute(list.getLocalName(i), prefix, list.getURI(i), expression); } }
protected void configureStaticTagAttributes(TagScript script, Attributes list) throws JellyException { // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeValue = list.getValue(i); Expression expression = CompositeExpression.parse( attributeValue, getExpressionFactory() ); String attrQName = list.getQName(i); int p = attrQName.indexOf(':'); String prefix = p>=0 ? attrQName.substring(0,p): ""; script.addAttribute(list.getLocalName(i), prefix, list.getURI(i), expression); } }
/** * Adds the text to the current script block parsing any embedded * expressions into ExpressionScript objects. * * @param start * If the text precedes a start element. Otherwise the text precedes an end element. */ protected void addTextScript(String text, boolean start) throws JellyException { if (!preserveWhitespace.peek()) { // if we are preserving whitespace, don't touch anything if (lastSeenStart && !start) { // <a>...</a>. whitespace trimmed only if this includes expression if (text.indexOf("${")>=0) text = text.trim(); } // text node that consists entirely from whitespace is dropped if (text.trim().length()==0) return; } Expression expression = CompositeExpression.parse(text, getExpressionFactory()); addExpressionScript(script, expression); }
protected void configureStaticTagAttributes(TagScript script, Attributes list) throws JellyException { // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeValue = list.getValue(i); Expression expression = CompositeExpression.parse( attributeValue, getExpressionFactory() ); String attrQName = list.getQName(i); int p = attrQName.indexOf(':'); String prefix = p>=0 ? attrQName.substring(0,p): ""; script.addAttribute(list.getLocalName(i), prefix, list.getURI(i), expression); } }
/** * Recursively evaluate a string representation of a jelly expression. * * @param text String representation of the a Jelly expression. * @param context The Jelly context to compute the expression against. * * @return The recursively evaluated Jelly expression. */ public static Expression decomposeExpression( String text, JellyContext context ) { Expression expression = null; try { expression = CompositeExpression.parse( text, mavenExpressionFactory ); String expressionText = expression.evaluateAsString( context ); if ( CompositeExpression.parse( expressionText, mavenExpressionFactory ) instanceof CompositeExpression ) { expression = decomposeExpression( expressionText, context ); } } catch ( Exception e ) { // do nothing. } return expression; }
/** * Adds the text to the current script block parsing any embedded * expressions into ExpressionScript objects. * * @param start * If the text precedes a start element. Otherwise the text precedes an end element. */ protected void addTextScript(String text, boolean start) throws JellyException { if (!preserveWhitespace.peek()) { // if we are preserving whitespace, don't touch anything if (lastSeenStart && !start) { // <a>...</a>. whitespace trimmed only if this includes expression if (text.indexOf("${")>=0) text = text.trim(); } // text node that consists entirely from whitespace is dropped if (text.trim().length()==0) return; } Expression expression = CompositeExpression.parse(text, getExpressionFactory()); addExpressionScript(script, expression); }
/** * Adds the text to the current script block parsing any embedded * expressions into ExpressionScript objects. * * @param start * If the text precedes a start element. Otherwise the text precedes an end element. */ protected void addTextScript(String text, boolean start) throws JellyException { if (!preserveWhitespace.peek()) { // if we are preserving whitespace, don't touch anything if (lastSeenStart && !start) { // <a>...</a>. whitespace trimmed only if this includes expression if (text.indexOf("${")>=0) text = text.trim(); } // text node that consists entirely from whitespace is dropped if (text.trim().length()==0) return; } Expression expression = CompositeExpression.parse(text, getExpressionFactory()); addExpressionScript(script, expression); }
/** * Adds the text to the current script block parsing any embedded * expressions inot ExpressionScript objects. */ protected void addTextScript(String text) throws JellyException { Expression expression = CompositeExpression.parse(text, getExpressionFactory()); addExpressionScript(script, expression); }
/** Allows taglibs to use their own expression evaluation mechanism */ public Expression createExpression( ExpressionFactory factory, TagScript tagScript, String attributeName, String attributeValue) throws JellyException { ExpressionFactory myFactory = getExpressionFactory(); if (myFactory == null) { myFactory = factory; } if (myFactory != null) { return CompositeExpression.parse(attributeValue, myFactory); } // will use a constant expression instead return new ConstantExpression(attributeValue); }
/** Allows taglibs to use their own expression evaluation mechanism */ public Expression createExpression( ExpressionFactory factory, TagScript tagScript, String attributeName, String attributeValue) throws JellyException { ExpressionFactory myFactory = getExpressionFactory(); if (myFactory == null) { myFactory = factory; } if (myFactory != null) { return CompositeExpression.parse(attributeValue, myFactory); } // will use a constant expression instead return new ConstantExpression(attributeValue); }
/** Allows taglibs to use their own expression evaluation mechanism */ public Expression createExpression( ExpressionFactory factory, TagScript tagScript, String attributeName, String attributeValue) throws JellyException { ExpressionFactory myFactory = getExpressionFactory(); if (myFactory == null) { myFactory = factory; } if (myFactory != null) { return CompositeExpression.parse(attributeValue, myFactory); } // will use a constant expression instead return new ConstantExpression(attributeValue); }
/** Allows taglibs to use their own expression evaluation mechanism */ public Expression createExpression( ExpressionFactory factory, TagScript tagScript, String attributeName, String attributeValue) throws JellyException { ExpressionFactory myFactory = getExpressionFactory(); if (myFactory == null) { myFactory = factory; } if (myFactory != null) { return CompositeExpression.parse(attributeValue, myFactory); } // will use a constant expression instead return new ConstantExpression(attributeValue); }
Expression expr = CompositeExpression.parse( literalValue, factory );
for (int i = 0; i < size; i++) { String attributeValue = list.getValue(i); Expression expression = CompositeExpression.parse( attributeValue, getExpressionFactory() );
protected void assertExpression(String expressionText, Object expectedValue) throws Exception { Expression expression = CompositeExpression.parse(expressionText, factory); assertTrue( "Created a valid expression for: " + expressionText, expression != null ); Object value = expression.evaluate(context); //assertEquals( "Expression for: " + expressionText + " is: " + expression, expectedValue, value ); assertEquals( "Wrong result for expression: " + expressionText, expectedValue, value ); } }
protected void assertExpression(String expressionText, Object expectedValue) throws Exception { Expression expression = CompositeExpression.parse(expressionText, factory); assertTrue( "Created a valid expression for: " + expressionText, expression != null ); Object value = expression.evaluate(context); assertEquals( "Wrong result for expression: " + expressionText, expectedValue, value ); String text = expression.getExpressionText(); assertEquals( "Wrong textual representation for expression text: ", expressionText, text); } }