You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2017/07/01 08:50:22 UTC

svn commit: r1800482 - in /commons/proper/jexl/trunk: RELEASE-NOTES.txt src/main/java/org/apache/commons/jexl3/JexlArithmetic.java src/site/xdoc/changes.xml src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java

Author: henrib
Date: Sat Jul  1 08:50:21 2017
New Revision: 1800482

URL: http://svn.apache.org/viewvc?rev=1800482&view=rev
Log:
JEXL-234: updated JexlArithmetic.start,ends}With to use CharSequence as first param

Modified:
    commons/proper/jexl/trunk/RELEASE-NOTES.txt
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
    commons/proper/jexl/trunk/src/site/xdoc/changes.xml
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java

Modified: commons/proper/jexl/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/RELEASE-NOTES.txt?rev=1800482&r1=1800481&r2=1800482&view=diff
==============================================================================
--- commons/proper/jexl/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/jexl/trunk/RELEASE-NOTES.txt Sat Jul  1 08:50:21 2017
@@ -25,9 +25,15 @@ Release 3.2
 
 Version 3.2 is a minor release.
 
+New Features in 3.2:
+====================
+* JEXL-234:      Extend application of operators startsWith and endsWith from String to CharSequence types
+* JEXL-226:      add ?? operator support
+
+Bugs Fixed in 3.2:
+==================
 * JEXL-231:      Syntax for accessing List elements is not mentioned in docs
 * JEXL-230:      List literal is not mentioned in docs
-* JEXL-226:      add ?? operator support
 
 There are no other changes.
 

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java?rev=1800482&r1=1800481&r2=1800482&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java Sat Jul  1 08:50:21 2017
@@ -883,8 +883,8 @@ public class JexlArithmetic {
             // we know both aren't null, therefore L != R
             return false;
         }
-        if (left instanceof String) {
-            return ((String) left).endsWith(toString(right));
+        if (left instanceof CharSequence) {
+            return (toString(left)).endsWith(toString(right));
         }
         return null;
     }
@@ -905,8 +905,8 @@ public class JexlArithmetic {
             // we know both aren't null, therefore L != R
             return false;
         }
-        if (left instanceof String) {
-            return ((String) left).startsWith(toString(right));
+        if (left instanceof CharSequence) {
+            return (toString(left)).startsWith(toString(right));
         }
         return null;
     }

Modified: commons/proper/jexl/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/site/xdoc/changes.xml?rev=1800482&r1=1800481&r2=1800482&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/jexl/trunk/src/site/xdoc/changes.xml Sat Jul  1 08:50:21 2017
@@ -26,6 +26,9 @@
     </properties>
     <body>
         <release version="3.1.1" date="unreleased">
+            <action dev="henrib" type="add" issue="JEXL-234" due-to="Dmitri Blinov">
+                Extend application of operators startsWith and endsWith from String to CharSequence types
+            </action>
             <action dev="henrib" type="fix" issue="JEXL-231" due-to="Dmitri Blinov">
                 Syntax for accessing List elements is not mentioned in docs
             </action>

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java?rev=1800482&r1=1800481&r2=1800482&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java Sat Jul  1 08:50:21 2017
@@ -124,6 +124,26 @@ public class ArithmeticOperatorTest exte
         asserter.assertExpression("x.y !$ 'foo'", Boolean.FALSE);
     }
 
+    @Test
+    public void testStartsEndsWithStringBuilder() throws Exception {
+        asserter.setVariable("x", new StringBuilder("foobar"));
+        asserter.assertExpression("x =^ 'foo'", Boolean.TRUE);
+        asserter.assertExpression("x =$ 'foo'", Boolean.FALSE);
+        asserter.setVariable("x", new StringBuilder("barfoo"));
+        asserter.assertExpression("x =^ 'foo'", Boolean.FALSE);
+        asserter.assertExpression("x =$ 'foo'", Boolean.TRUE);
+    }
+
+    @Test
+    public void testNotStartsEndsWithStringBuilder() throws Exception {
+        asserter.setVariable("x", new StringBuilder("foobar"));
+        asserter.assertExpression("x !^ 'foo'", Boolean.FALSE);
+        asserter.assertExpression("x !$ 'foo'", Boolean.TRUE);
+        asserter.setVariable("x", new StringBuilder("barfoo"));
+        asserter.assertExpression("x !^ 'foo'", Boolean.TRUE);
+        asserter.assertExpression("x !$ 'foo'", Boolean.FALSE);
+    }
+
     public static class MatchingContainer {
         private final Set<Integer> values;