This is an automated email from the ASF dual-hosted git repository.

ramyav pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/olingo-odata4.git


The following commit(s) were added to refs/heads/master by this push:
     new 1df2f4a  [OLINGO-1417]Serach query to support +
1df2f4a is described below

commit 1df2f4aa67e9ed5c3cc10f3abc65f9e1fd7ee042
Author: ramya vasanth <ramya.vasa...@sap.com>
AuthorDate: Tue Jan 14 14:57:02 2020 +0530

    [OLINGO-1417]Serach query to support +
---
 .../core/uri/parser/search/SearchTokenizer.java    | 35 ++++++++++++++--------
 .../uri/parser/search/SearchTokenizerTest.java     |  1 +
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git 
a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizer.java
 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizer.java
index 6a40e00..f89eca0 100644
--- 
a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizer.java
+++ 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizer.java
@@ -54,9 +54,6 @@ public class SearchTokenizer {
     protected static final char CHAR_R = 'R';
     protected static final char CHAR_CLOSE = ')';
     protected static final char CHAR_OPEN = '(';
-    protected static final char CHAR_COMMA = ',';
-    protected static final char CHAR_DOT = '.';
-    protected static final char CHAR_HYPEN = '-';
 
     public State() {}
 
@@ -123,10 +120,8 @@ public class SearchTokenizer {
 
     static boolean isAllowedWord(final char character) {
       return Character.isUnicodeIdentifierStart(character)
-          || Character.DASH_PUNCTUATION == Character.getType(character)
-          || Character.DECIMAL_DIGIT_NUMBER == Character.getType(character) 
-          || (Character.OTHER_PUNCTUATION == Character.getType(character) && 
-          (character != ';' && character != '"'));
+          || isUnreserved(character)
+          || isOtherDelimsForWord(character);
     }
     
     /**
@@ -207,6 +202,26 @@ public class SearchTokenizer {
     }
 
     /**
+     * other-delims = "!" / "(" / ")" / "*" / "+" / "," / ";"
+     * @param character which is checked
+     * @return true if character is allowed
+     */
+    private static boolean isOtherDelimsForWord(final char character) {
+      return character == '!'
+          || character == '*'
+          || character == '+'
+          || character == ','
+          || character == ':'
+          || character == '@'
+          || character == '/'
+          || character == '?'
+          || character == '$'
+          || character == '='
+          || character == '%'
+          || character == '\'';
+    }
+    
+    /**
      * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
      * @param character which is checked
      * @return true if character is allowed
@@ -352,11 +367,7 @@ public class SearchTokenizer {
 
     @Override
     public State nextChar(final char c) throws SearchTokenizerException {
-      if (isAllowedWord(c) ||
-          ('0' <= c && c <= '9') ||
-          (c == CHAR_COMMA) ||
-          (c == CHAR_DOT) ||
-          (c == CHAR_HYPEN)) {
+      if (isAllowedWord(c)) {
         return allowed(c);
       } else if (c == CHAR_CLOSE) {
         finish();
diff --git 
a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerTest.java
 
b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerTest.java
index 216323d..47ac334 100644
--- 
a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerTest.java
+++ 
b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/parser/search/SearchTokenizerTest.java
@@ -45,6 +45,7 @@ public class SearchTokenizerTest {
 
   @Test
   public void parseWords() throws Exception {
+    assertQuery("C++%20=$@:,*!/?'%27").resultsIn(WORD);
     assertQuery("somesimpleword").resultsIn(WORD);
     assertQuery("anotherWord\u1234").resultsIn(WORD);
     // special

Reply via email to