if (readIf("(")) {
r = readFunction(null, name);
} else if (readIf(".")) {
r = readTermObjectDot(name);
} else {
r = new ExpressionColumn(database, null, null, name);
}
} else {
read();
if (equalsToken("X", name) && currentTokenType == VALUE && currentValue.getType() == Value.STRING) {
read();
byte[] buffer = StringUtils.convertStringToBytes(currentValue.getString());
r = ValueExpression.get(ValueBytes.getNoCopy(buffer));
} else if (readIf(".")) {
r = readTermObjectDot(name);
} else if (equalsToken("CASE", name)) {
// CASE must be processed before (,
// otherwise CASE(3) would be a function call, which it is
// not
if (isToken("WHEN")) {
r = readWhen(null);
} else {
Expression left = readExpression();
r = readWhen(left);
}
} else if (readIf("(")) {
r = readFunction(null, name);
} else if (equalsToken("CURRENT_USER", name)) {
r = readFunctionWithoutParameters("USER");
} else if (equalsToken("CURRENT", name)) {
if (readIf("TIMESTAMP")) {
r = readFunctionWithoutParameters("CURRENT_TIMESTAMP");
} else if (readIf("TIME")) {
r = readFunctionWithoutParameters("CURRENT_TIME");
} else if (readIf("DATE")) {
r = readFunctionWithoutParameters("CURRENT_DATE");
} else {
r = new ExpressionColumn(database, null, null, name);
}
} else if (equalsToken("NEXT", name) && readIf("VALUE")) {
read("FOR");
Sequence sequence = readSequence();
r = new SequenceValue(sequence);
} else if (equalsToken("DATE", name) && currentTokenType == VALUE && currentValue.getType() == Value.STRING) {
String date = currentValue.getString();
read();
r = ValueExpression.get(ValueDate.get(ValueDate.parseDate(date)));
} else if (equalsToken("TIME", name) && currentTokenType == VALUE && currentValue.getType() == Value.STRING) {
String time = currentValue.getString();
read();
r = ValueExpression.get(ValueTime.get(ValueTime.parseTime(time)));
} else if (equalsToken("TIMESTAMP", name) && currentTokenType == VALUE
&& currentValue.getType() == Value.STRING) {
String timestamp = currentValue.getString();
read();
r = ValueExpression.get(ValueTimestamp.getNoCopy(ValueTimestamp.parseTimestamp(timestamp)));
} else if (equalsToken("E", name) && currentTokenType == VALUE && currentValue.getType() == Value.STRING) {
String text = currentValue.getString();
// the PostgreSQL ODBC driver uses
// LIKE E'PROJECT\\_DATA' instead of LIKE 'PROJECT\_DATA'
text = StringUtils.replaceAll(text, "\\\\", "\\");
read();
r = ValueExpression.get(ValueString.get(text));
} else {
r = new ExpressionColumn(database, null, null, name);
}
}
break;
case MINUS:
read();