public PredicateLeafImpl( PredicateLeaf.Operator @operator, Type type, string columnName, object literal, List <object> literalList) { this.@operator = @operator; this.type = type; this.columnName = columnName; this.literal = literal; if (literal != null) { if (literal.GetType() != type.getValueClass()) { throw new ArgumentException("Wrong value class " + literal.GetType().Name + " for " + type + "." + @operator + " leaf"); } } this.literalList = literalList; if (literalList != null) { System.Type valueCls = type.getValueClass(); foreach (object lit in literalList) { if (lit != null && lit.GetType() != valueCls) { throw new ArgumentException("Wrong value class item " + lit.GetType().Name + " for " + type + "." + @operator + " leaf"); } } } }
/** * Create a predicate leaf. This is used by another test. */ public static PredicateLeaf createPredicateLeaf(PredicateLeaf.Operator @operator, PredicateLeaf.Type type, string columnName, object literal, List <object> literalList) { return(new SearchArgumentImpl.PredicateLeafImpl(@operator, type, columnName, literal, literalList)); }
/** * Create a leaf expression when we aren't sure where the variable is * located. * @param operator the operator type that was found * @param expression the expression to check */ private void createLeaf(PredicateLeaf.Operator @operator, ExprNodeGenericFuncDesc expression) { createLeaf(@operator, expression, findVariable(expression)); }
private void createLeaf(PredicateLeaf.Operator @operator, ExprNodeGenericFuncDesc expression, int variable) { string columnName = getColumnName(expression, variable); if (columnName == null) { builder.literal(TruthValue.YES_NO_NULL); return; } PredicateLeaf.Type type = getType(expression.getChildren().get(variable)); if (type == null) { builder.literal(TruthValue.YES_NO_NULL); return; } // if the variable was on the right, we need to swap things around bool needSwap = false; if (variable != 0) { if (@operator == PredicateLeaf.Operator.LESS_THAN) { needSwap = true; @operator = PredicateLeaf.Operator.LESS_THAN_EQUALS; } else if (@operator == PredicateLeaf.Operator.LESS_THAN_EQUALS) { needSwap = true; @operator = PredicateLeaf.Operator.LESS_THAN; } } if (needSwap) { builder.startNot(); } switch (@operator) { case PredicateLeaf.Operator.IS_NULL: builder.isNull(columnName, type); break; case PredicateLeaf.Operator.EQUALS: builder.equals(columnName, type, findLiteral(expression, type)); break; case PredicateLeaf.Operator.NULL_SAFE_EQUALS: builder.nullSafeEquals(columnName, type, findLiteral(expression, type)); break; case PredicateLeaf.Operator.LESS_THAN: builder.lessThan(columnName, type, findLiteral(expression, type)); break; case PredicateLeaf.Operator.LESS_THAN_EQUALS: builder.lessThanEquals(columnName, type, findLiteral(expression, type)); break; case PredicateLeaf.Operator.IN: builder.@in(columnName, type, getLiteralList(expression, type, variable + 1)); break; case PredicateLeaf.Operator.BETWEEN: builder.between(columnName, type, getLiteral(expression, type, variable + 1), getLiteral(expression, type, variable + 2)); break; } if (needSwap) { builder.end(); } }
public PredicateLeafImpl( PredicateLeaf.Operator @operator, Type type, string columnName, object literal, List<object> literalList) { this.@operator = @operator; this.type = type; this.columnName = columnName; this.literal = literal; if (literal != null) { if (literal.GetType() != type.getValueClass()) { throw new ArgumentException("Wrong value class " + literal.GetType().Name + " for " + type + "." + @operator + " leaf"); } } this.literalList = literalList; if (literalList != null) { System.Type valueCls = type.getValueClass(); foreach (object lit in literalList) { if (lit != null && lit.GetType() != valueCls) { throw new ArgumentException("Wrong value class item " + lit.GetType().Name + " for " + type + "." + @operator + " leaf"); } } } }