[OLINGO-1417]Serach query to support +
This commit is contained in:
parent
cb6a7ce346
commit
1df2f4aa67
|
@ -54,9 +54,6 @@ public class SearchTokenizer {
|
||||||
protected static final char CHAR_R = 'R';
|
protected static final char CHAR_R = 'R';
|
||||||
protected static final char CHAR_CLOSE = ')';
|
protected static final char CHAR_CLOSE = ')';
|
||||||
protected static final char CHAR_OPEN = '(';
|
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() {}
|
public State() {}
|
||||||
|
|
||||||
|
@ -123,10 +120,8 @@ public class SearchTokenizer {
|
||||||
|
|
||||||
static boolean isAllowedWord(final char character) {
|
static boolean isAllowedWord(final char character) {
|
||||||
return Character.isUnicodeIdentifierStart(character)
|
return Character.isUnicodeIdentifierStart(character)
|
||||||
|| Character.DASH_PUNCTUATION == Character.getType(character)
|
|| isUnreserved(character)
|
||||||
|| Character.DECIMAL_DIGIT_NUMBER == Character.getType(character)
|
|| isOtherDelimsForWord(character);
|
||||||
|| (Character.OTHER_PUNCTUATION == Character.getType(character) &&
|
|
||||||
(character != ';' && character != '"'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -206,6 +201,26 @@ public class SearchTokenizer {
|
||||||
|| character == ';';
|
|| character == ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 / "-" / "." / "_" / "~"
|
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
||||||
* @param character which is checked
|
* @param character which is checked
|
||||||
|
@ -352,11 +367,7 @@ public class SearchTokenizer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State nextChar(final char c) throws SearchTokenizerException {
|
public State nextChar(final char c) throws SearchTokenizerException {
|
||||||
if (isAllowedWord(c) ||
|
if (isAllowedWord(c)) {
|
||||||
('0' <= c && c <= '9') ||
|
|
||||||
(c == CHAR_COMMA) ||
|
|
||||||
(c == CHAR_DOT) ||
|
|
||||||
(c == CHAR_HYPEN)) {
|
|
||||||
return allowed(c);
|
return allowed(c);
|
||||||
} else if (c == CHAR_CLOSE) {
|
} else if (c == CHAR_CLOSE) {
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -45,6 +45,7 @@ public class SearchTokenizerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseWords() throws Exception {
|
public void parseWords() throws Exception {
|
||||||
|
assertQuery("C++%20=$@:,*!/?'%27").resultsIn(WORD);
|
||||||
assertQuery("somesimpleword").resultsIn(WORD);
|
assertQuery("somesimpleword").resultsIn(WORD);
|
||||||
assertQuery("anotherWord\u1234").resultsIn(WORD);
|
assertQuery("anotherWord\u1234").resultsIn(WORD);
|
||||||
// special
|
// special
|
||||||
|
|
Loading…
Reference in New Issue