blob: 1faab42fc86c740a93bb7b1c3c12db79150b0ad5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.select.simple;
/**
* @author baldersheim
*/
public class OperatorParser extends Parser {
private String operator;
public String getOperator() { return operator; }
public boolean parse(CharSequence s) {
boolean retval = false;
int pos = eatWhite(s);
if (pos+1 < s.length()) {
retval = true;
int startPos = pos;
if (s.charAt(pos) == '=') {
pos++;
if ((s.charAt(pos) == '=') || (s.charAt(pos) == '~')) {
pos++;
}
} else if (s.charAt(pos) == '>') {
pos++;
if (s.charAt(pos) == '=') {
pos++;
}
} else if (s.charAt(pos) == '<') {
pos++;
if (s.charAt(pos) == '=') {
pos++;
}
} else if ((s.charAt(pos) == '!') && (s.charAt(pos) == '=')) {
pos += 2;
} else {
retval = false;
}
if (retval) {
operator = s.subSequence(startPos, pos).toString();
}
}
setRemaining(s.subSequence(pos, s.length()));
return retval;
}
}
|