qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [2/2] qpid-jms git commit: add use of escaped quotes as condensed alternative for the 'hyphenated parser'
Date Mon, 02 Mar 2015 18:12:24 GMT
add use of escaped quotes as condensed alternative for the 'hyphenated parser'


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/fd2139c2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/fd2139c2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/fd2139c2

Branch: refs/heads/master
Commit: fd2139c27d96126f0cef9a6b55701f439b21f6dc
Parents: fa5f720
Author: Robert Gemmell <robbie@apache.org>
Authored: Mon Mar 2 18:00:59 2015 +0000
Committer: Robert Gemmell <robbie@apache.org>
Committed: Mon Mar 2 18:02:15 2015 +0000

----------------------------------------------------------------------
 qpid-jms-client/src/main/javacc/StrictParser.jj      | 15 +++++++++++++++
 .../org/apache/qpid/jms/selector/SelectorTest.java   |  8 ++++++++
 2 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/fd2139c2/qpid-jms-client/src/main/javacc/StrictParser.jj
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/javacc/StrictParser.jj b/qpid-jms-client/src/main/javacc/StrictParser.jj
index dfe8dab..b095209 100755
--- a/qpid-jms-client/src/main/javacc/StrictParser.jj
+++ b/qpid-jms-client/src/main/javacc/StrictParser.jj
@@ -131,6 +131,7 @@ TOKEN [IGNORE_CASE] :
 TOKEN [IGNORE_CASE] :
 {
     < ID : ["a"-"z", "_", "$"] (["a"-"z","0"-"9","_", "$"])* >
+    | < QUOTED_ID : "\"" ( ("\"\"") | ~["\""] )*  "\""  >
 }
 
 // ----------------------------------------------------------------------------
@@ -556,6 +557,20 @@ PropertyExpression variable() :
         {
             left = new PropertyExpression(t.image);
         }
+        |
+        t = <QUOTED_ID>
+        {
+            // Decode the string value.
+            StringBuffer rc = new StringBuffer();
+            String image = t.image;
+            for( int i=1; i < image.length()-1; i++ ) {
+                char c = image.charAt(i);
+                if( c == '"' )
+                    i++;
+                rc.append(c);
+            }
+            return new PropertyExpression(rc.toString());
+        }
     )
     {
         return left;

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/fd2139c2/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorTest.java
index 97590ba..a103f9a 100755
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/selector/SelectorTest.java
@@ -429,6 +429,14 @@ public class SelectorTest extends TestCase {
         assertInvalidSelector(message, "=TEST 'test'");
     }
 
+    public void testHyphenatedProperty() throws Exception {
+        MockMessage message = createMessage();
+        message.setStringProperty("hyphenated-prop", "val");
+
+        assertSelector(message, "\"hyphenated-prop\" = 'val'", true);
+        assertSelector(message, "\"hyphenated-prop\" = 'other'", false);
+    }
+
     protected MockMessage createMessage() {
         MockMessage message = createMessage("FOO.BAR");
         message.setJMSType("selector-test");


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message