/** * Determine whether Expression parameter is a binary value (0 or 1). * * @param expr * @return true if parameter is 0/1, false for others. */ public static boolean isBinaryValue(Expression expr) { boolean rtn = false; if (expr instanceof LongValue) { long l = ((LongValue) expr).getValue(); rtn = ((l == 0) || (l == 1)); } return rtn; }
@Override protected Expression handlePredicateFunction(BinaryExpression expr) { log.debug("handlePredicateFunction: " + expr); if (expr.getLeftExpression() instanceof TextSearchMatch) { TextSearchMatch ts = (TextSearchMatch) expr.getLeftExpression(); log.debug("handlePredicateFunction: " + ts); if (expr.getRightExpression() instanceof LongValue) { long value = ((LongValue) expr.getRightExpression()).getValue(); log.debug("handlePredicateFunction: " + value); if (value == 0) { log.debug("handlePredicateFunction: negate"); ts.negate(); } } return ts; } return expr; }
public static Object getValue(Expression incomingExpression, Expression otherSide, FieldType defaultFieldType, Map<String, FieldType> fieldNameToFieldTypeMapping) throws ParseException { FieldType fieldType = otherSide !=null ? firstNonNull(fieldNameToFieldTypeMapping.get(getStringValue(otherSide)), defaultFieldType) : FieldType.UNKNOWN; if (LongValue.class.isInstance(incomingExpression)) { return normalizeValue((((LongValue)incomingExpression).getValue()),fieldType); } else if (SignedExpression.class.isInstance(incomingExpression)) { return normalizeValue((((SignedExpression)incomingExpression).toString()),fieldType); } else if (StringValue.class.isInstance(incomingExpression)) { return normalizeValue((((StringValue)incomingExpression).getValue()),fieldType); } else if (Column.class.isInstance(incomingExpression)) { return normalizeValue(getStringValue(incomingExpression),fieldType); } else { throw new ParseException("can not parseNaturalLanguageDate: " + incomingExpression.toString()); } }
return ((StringValue) expression).getValue(); } else if (expression instanceof LongValue) { return ((LongValue) expression).getValue(); } else if (expression instanceof TimestampValue) { return ((TimestampValue) expression).getValue();
} else if (exp instanceof LongValue) { try { return new ConstantExpression(((LongValue) exp).getValue()); } catch (NumberFormatException largeNumber) { return new ConstantExpression(Double.valueOf(((LongValue) exp).getStringValue()));