/** * INTERNAL: * Return if the expression is equal to the other. * This is used to allow dynamic expression's SQL to be cached. */ public boolean equals(Object object) { if (this == object) { return true; } if (!super.equals(object)) { return false; } ConstantExpression expression = (ConstantExpression) object; return ((getValue() == expression.getValue()) || ((getValue() != null) && getValue().equals(expression.getValue()))); }
/** * INTERNAL: * Return if the expression is equal to the other. * This is used to allow dynamic expression's SQL to be cached. */ public boolean equals(Object object) { if (this == object) { return true; } if (!super.equals(object)) { return false; } ConstantExpression expression = (ConstantExpression) object; return ((getValue() == expression.getValue()) || ((getValue() != null) && getValue().equals(expression.getValue()))); }
/** * INTERNAL: * Used to print a debug form of the expression tree. */ public void writeDescriptionOn(BufferedWriter writer) throws IOException { writer.write(String.valueOf(getValue())); }
/** * INTERNAL: * Used to print a debug form of the expression tree. */ public void writeDescriptionOn(BufferedWriter writer) throws IOException { writer.write(String.valueOf(getValue())); }
/** * INTERNAL: * Return if the expression is equal to the other. * This is used to allow dynamic expression's SQL to be cached. */ public boolean equals(Object object) { if (this == object) { return true; } if (!super.equals(object)) { return false; } ConstantExpression expression = (ConstantExpression) object; return ((this.value == expression.getValue()) || ((this.value != null) && this.value.equals(expression.getValue()))); }
/** * INTERNAL: * Print java for project class generation */ public void printJava(ExpressionJavaPrinter printer) { printer.printJava(getValue()); }
/** * INTERNAL: * Print java for project class generation */ public void printJava(ExpressionJavaPrinter printer) { printer.printJava(getValue()); }
/** * INTERNAL: * Print SQL, this is called from functions, so must not be converted through the mapping. */ public void printSQLWithoutConversion(ExpressionSQLPrinter printer) { printer.printPrimitive(getValue()); }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { Object value = getLocalBase().getFieldValue(getValue(), getSession()); if(value == null) { printer.printNull(this); } else { printer.printPrimitive(value); } }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { Object value = getLocalBase().getFieldValue(getValue(), getSession()); if(value == null) { printer.printNull(this); } else { printer.printPrimitive(value); } }
/** * INTERNAL: * Prints the as of clause for an expression inside of the FROM clause. */ public void printSQL(ExpressionSQLPrinter printer) { printer.printString("AS OF TIMESTAMP ("); Object value = getValue(); if (value instanceof Expression) { // Sort of an implementation of native sql. // Print AS OF TIMESTAMP (SYSDATE - 1000*60*10) not AS OF ('SYSDATE - 1000*60*10'). if ((value instanceof ConstantExpression) && (((ConstantExpression)value).getValue() instanceof String)) { printer.printString((String)((ConstantExpression)value).getValue()); } else { printer.printExpression((Expression)value); } } else { ConversionManager converter = ConversionManager.getDefaultManager(); value = converter.convertObject(value, ClassConstants.TIMESTAMP); printer.printPrimitive(value); } printer.printString(")"); }
/** * Create a predicate that tests whether a collection is empty. * * @param collection * expression * @return predicate */ public <C extends Collection<?>> Predicate isEmpty(Expression<C> collection){ if (((InternalExpression)collection).isLiteral()){ if (((Collection)((ConstantExpression)((InternalSelection)collection).getCurrentNode()).getValue()).isEmpty()){ return conjunction(); }else{ return disjunction(); } } return new CompoundExpressionImpl(metamodel, ((InternalSelection)collection).getCurrentNode().size(ClassConstants.INTEGER).equal(0), buildList(collection), "isEmpty"); }
/** * Check if the expression is an equal null expression, these must be handle in a special way in SQL. */ public boolean isEqualNull(ExpressionSQLPrinter printer) { if (isObjectComparison()) { return false; } else if (this.operator.getSelector() != ExpressionOperator.Equal) { return false; } else if (this.secondChild.isConstantExpression() && (((ConstantExpression)this.secondChild).getValue() == null)) { return true; } else if (this.secondChild.isParameterExpression() && (printer.getTranslationRow() != null) && (((ParameterExpression)this.secondChild).getValue(printer.getTranslationRow(), printer.getSession()) == null)) { return true; } else { return false; } }
/** * Check if the expression is an equal null expression, these must be handle in a special way in SQL. */ public boolean isNotEqualNull(ExpressionSQLPrinter printer) { if (isObjectComparison()) { return false; } else if (this.operator.getSelector() != ExpressionOperator.NotEqual) { return false; } else if (this.secondChild.isConstantExpression() && (((ConstantExpression)this.secondChild).getValue() == null)) { return true; } else if (this.secondChild.isParameterExpression() && (printer.getTranslationRow() != null) && (((ParameterExpression)this.secondChild).getValue(printer.getTranslationRow(), printer.getSession()) == null)) { return true; } else { return false; } }
/** * Check if the expression is an equal null expression, these must be handle in a special way in SQL. */ public boolean isNotEqualNull(ExpressionSQLPrinter printer) { if (isObjectComparison(printer.getSession())) { return false; } else if (this.operator.getSelector() != ExpressionOperator.NotEqual) { return false; } else if (this.secondChild.isConstantExpression() && (((ConstantExpression)this.secondChild).getValue() == null)) { return true; } else if (this.secondChild.isParameterExpression() && (printer.getTranslationRow() != null) && (((ParameterExpression)this.secondChild).getValue(printer.getTranslationRow(), printer.getSession()) == null)) { return true; } else { return false; } }
/** * Check if the expression is an equal null expression, these must be handle in a special way in SQL. */ public boolean isEqualNull(ExpressionSQLPrinter printer) { if (isObjectComparison(printer.getSession())) { return false; } else if (this.operator.getSelector() != ExpressionOperator.Equal) { return false; } else if (this.secondChild.isConstantExpression() && (((ConstantExpression)this.secondChild).getValue() == null)) { return true; } else if (this.secondChild.isParameterExpression() && (printer.getTranslationRow() != null) && (((ParameterExpression)this.secondChild).getValue(printer.getTranslationRow(), printer.getSession()) == null)) { return true; } else { return false; } }
/** * Check if the expression is an equal null expression, these must be handle in a special way in SQL. */ public boolean isNotEqualNull(ExpressionSQLPrinter printer) { if (isObjectComparison(printer.getSession())) { return false; } else if (this.operator.getSelector() != ExpressionOperator.NotEqual) { return false; } else if (this.secondChild.isConstantExpression() && (((ConstantExpression)this.secondChild).getValue() == null)) { return true; } else if (this.secondChild.isParameterExpression() && (printer.getTranslationRow() != null) && (((ParameterExpression)this.secondChild).getValue(printer.getTranslationRow(), printer.getSession()) == null)) { return true; } else { return false; } }
/** * Check if the expression is an equal null expression, these must be handle in a special way in SQL. */ public boolean isEqualNull(ExpressionSQLPrinter printer) { if (isObjectComparison(printer.getSession())) { return false; } else if (this.operator.getSelector() != ExpressionOperator.Equal) { return false; } else if (this.secondChild.isConstantExpression() && (((ConstantExpression)this.secondChild).getValue() == null)) { return true; } else if (this.secondChild.isParameterExpression() && (printer.getTranslationRow() != null) && (((ParameterExpression)this.secondChild).getValue(printer.getTranslationRow(), printer.getSession()) == null)) { return true; } else { return false; } }