[jira] [Created] (JEXL-139) Loop over an iterable, evalaute and expression per row, and return concatenated results
Manoj Mokashi created JEXL-139: -- Summary: Loop over an iterable, evalaute and expression per row, and return concatenated results Key: JEXL-139 URL: https://issues.apache.org/jira/browse/JEXL-139 Project: Commons JEXL Issue Type: New Feature Reporter: Manoj Mokashi Priority: Minor Code below. /** * Iterates over the iterable represented by iterExpression * For each row, evaluate the row-expression * Return a string of all row-results, concatenated by separator. * The current current row is indicated by $$__EVAL_ROW and the current index by $$__EVAL_ROWNUM * @param enumExpression * @param expression * @return */ public String evalExprOverIter( String iterExpression, String rowExpression, String separator){ Object objIter = evalExpr( iterExpression); if( objIter == null ){ return "";} Iterable iterabl = null; if( objIter.getClass().isArray()){ iterabl = Arrays.asList( (Object[]) objIter ); } else if( objIter instanceof Map){ iterabl = ((Map) objIter).entrySet(); } else { iterabl = (Iterable) objIter; } Iterator iter = iterabl.iterator(); StringBuilder sbld = new StringBuilder(); int rownum = 0; while( iter.hasNext()){ Object row = iter.next(); setVar( "$$__EVAL_ROW", row ); setVar( "$$__EVAL_ROWNUM", rownum ); sbld.append( evalExpr( rowExpression) ); sbld.append( separator ); rownum++; } // remove the temp variables we used. remVar( "$$__EVAL_ROWNUM" ); remVar( "$$__EVAL_ROW" ); return sbld.deleteCharAt( sbld.length()-1).toString(); -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (JEXL-134) Issue with evaluation of concat of variables : \r + \n gives 0
[ https://issues.apache.org/jira/browse/JEXL-134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13404897#comment-13404897 ] Manoj Mokashi commented on JEXL-134: Hi Henri, thanks for the quick resolution :) > Issue with evaluation of concat of variables : \r + \n gives 0 > -- > > Key: JEXL-134 > URL: https://issues.apache.org/jira/browse/JEXL-134 > Project: Commons JEXL > Issue Type: Bug >Affects Versions: 2.1.1 > Environment: Windows Xp, jdk1.6.0_14 >Reporter: Manoj Mokashi >Assignee: Henri Biestro > Fix For: 2.1.2 > > > Consider the following example : > String jexlExp = "$$__INPUT + nl"; > Expression e = jexl.createExpression( jexlExp ); > // Create a context and add data > JexlContext jc = new MapContext(); > jc.set("$$__INPUT", "\r" ); > jc.set("nl", "\n"); > // Now evaluate the expression, getting the result > Object o = e.evaluate(jc); > The result is 0 instead of "\r\n" -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Created] (JEXL-134) Issue with evaluation of concat of variables : \r + \n gives 0
Manoj Mokashi created JEXL-134: -- Summary: Issue with evaluation of concat of variables : \r + \n gives 0 Key: JEXL-134 URL: https://issues.apache.org/jira/browse/JEXL-134 Project: Commons JEXL Issue Type: Bug Affects Versions: 2.1.1 Environment: Windows Xp, jdk1.6.0_14 Reporter: Manoj Mokashi Consider the following example : String jexlExp = "$$__INPUT + nl"; Expression e = jexl.createExpression( jexlExp ); // Create a context and add data JexlContext jc = new MapContext(); jc.set("$$__INPUT", "\r" ); jc.set("nl", "\n"); // Now evaluate the expression, getting the result Object o = e.evaluate(jc); The result is 0 instead of "\r\n" -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira