in oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java [1096:1201]
private void initialize(String query) throws ParseException {
if (query == null) {
query = "";
}
statement = query;
int len = query.length() + 1;
char[] command = new char[len];
int[] types = new int[len];
len--;
query.getChars(0, len, command, 0);
command[len] = ' ';
int startLoop = 0;
for (int i = 0; i < len; i++) {
char c = command[i];
int type = 0;
switch (c) {
case '-':
case '(':
case ')':
case '{':
case '}':
case '*':
case ',':
case ';':
case '+':
case '%':
case '?':
case '$':
type = CHAR_SPECIAL_1;
break;
case '!':
case '<':
case '>':
case '|':
case '=':
case ':':
type = CHAR_SPECIAL_2;
break;
case '.':
type = CHAR_DECIMAL;
break;
case '/':
if (command[i + 1] != '*') {
type = CHAR_SPECIAL_1;
break;
}
types[i] = type = CHAR_IGNORE;
startLoop = i;
i += 2;
checkRunOver(i, len, startLoop);
while (command[i] != '*' || command[i + 1] != '/') {
i++;
checkRunOver(i, len, startLoop);
}
i++;
break;
case '[':
types[i] = type = CHAR_BRACKETED;
startLoop = i;
while (true) {
while (command[++i] != ']') {
checkRunOver(i, len, startLoop);
}
if (i >= len - 1 || command[i + 1] != ']') {
break;
}
i++;
}
break;
case '\'':
types[i] = type = CHAR_STRING;
startLoop = i;
while (command[++i] != '\'') {
checkRunOver(i, len, startLoop);
}
break;
case '\"':
types[i] = type = CHAR_QUOTED;
startLoop = i;
while (command[++i] != '\"') {
checkRunOver(i, len, startLoop);
}
break;
case '_':
type = CHAR_NAME;
break;
default:
if (c >= 'a' && c <= 'z') {
type = CHAR_NAME;
} else if (c >= 'A' && c <= 'Z') {
type = CHAR_NAME;
} else if (c >= '0' && c <= '9') {
type = CHAR_VALUE;
} else {
if (Character.isJavaIdentifierPart(c)) {
type = CHAR_NAME;
}
}
}
types[i] = (byte) type;
}
statementChars = command;
types[len] = CHAR_END;
characterTypes = types;
parseIndex = 0;
}