/** * INTERNAL: * Build operator. * Note: This operator works differently from other operators. * @see Expression#caseStatement(Map, Object) */ public static ExpressionOperator caseStatement() { ListExpressionOperator exOperator = new ListExpressionOperator(); exOperator.setType(FunctionOperator); exOperator.setSelector(Case); exOperator.bePrefix(); exOperator.setNodeClass(ClassConstants.ArgumentListFunctionExpression_Class); exOperator.setIsBindingSupported(false); exOperator.setStartString("CASE "); exOperator.setSeparators(new String[]{" WHEN ", " THEN "}); exOperator.setTerminationStrings(new String[]{" ELSE ", " END"}); return exOperator; }
/** * INTERNAL: */ public void initializePlatformOperator(DatabasePlatform platform) { super.initializePlatformOperator(platform); ((ListExpressionOperator)platformOperator).setNumberOfItems(((ListExpressionOperator)operator).getNumberOfItems()); }
/** * INTERNAL: * Build operator. * Note: This operator works differently from other operators. * @see Expression#caseStatement(Map, Object) */ public static ExpressionOperator coalesce() { ListExpressionOperator exOperator = new ListExpressionOperator(); exOperator.setType(FunctionOperator); exOperator.setSelector(Coalesce); exOperator.bePrefix(); exOperator.setNodeClass(ClassConstants.ArgumentListFunctionExpression_Class); exOperator.setStartString("COALESCE("); exOperator.setSeparator(","); exOperator.setTerminationString(" )"); return exOperator; }
/** * INTERNAL: * Build operator. * Note: This operator works differently from other operators. * @see Expression#caseStatement(Map, String) */ public static ExpressionOperator caseStatement() { ListExpressionOperator exOperator = new ListExpressionOperator(); exOperator.setType(FunctionOperator); exOperator.setSelector(Case); exOperator.bePrefix(); exOperator.setNodeClass(FunctionExpression.class); exOperator.setIsBindingSupported(false); return exOperator; }
public ArgumentListFunctionExpression coalesce() { ListExpressionOperator coalesceOperator = (ListExpressionOperator)getOperator(ExpressionOperator.Coalesce); ListExpressionOperator clonedCoalesceOperator = new ListExpressionOperator(); coalesceOperator.copyTo(clonedCoalesceOperator); ArgumentListFunctionExpression expression = new ArgumentListFunctionExpression(); expression.setBaseExpression(this); expression.setOperator(clonedCoalesceOperator); return expression; }
private static final ExpressionOperator createCoalesceOperator() { ListExpressionOperator operator = (ListExpressionOperator) ExpressionOperator.coalesce(); operator.setStartString("VALUE("); operator.setSelector(ExpressionOperator.Coalesce); return operator; }
/** * INTERNAL: * Print SQL */ public void printSQL(ExpressionSQLPrinter printer) { ListExpressionOperator platformOperator = (ListExpressionOperator)getPlatformOperator(printer.getPlatform()); platformOperator.copyTo(operator); ((ListExpressionOperator)operator).setIsComplete(true); operator.printCollection(getChildren(), printer); }
@Override protected void postCopyIn(Map alreadyDone) { ((ListExpressionOperator)operator).setNumberOfItems(0); Boolean hasLastChildCopy = hasLastChild; hasLastChild = null; super.postCopyIn(alreadyDone); hasLastChild = hasLastChildCopy; }
/** * INTERNAL: * Add a new Expression to the list of arguments. * This method will update the list of arguments and any constant strings that are required * to be printed with the arguments * @param argument */ @Override public synchronized void addChild(Expression argument){ if (hasLastChild != null && hasLastChild.booleanValue()){ getChildren().add(getChildren().size() - 1, argument); } else { super.addChild(argument); } setBaseExpression((Expression)getChildren().firstElement()); ((ListExpressionOperator)operator).incrementNumberOfItems(); }
/** * INTERNAL: * Print SQL */ public void printSQL(ExpressionSQLPrinter printer) { ListExpressionOperator platformOperator = (ListExpressionOperator)getPlatformOperator(printer.getPlatform()); platformOperator.copyTo(operator); operator.printCollection(getChildren(), printer); }
public ArgumentListFunctionExpression coalesce() { ListExpressionOperator coalesceOperator = (ListExpressionOperator)getOperator(ExpressionOperator.Coalesce); ListExpressionOperator clonedCoalesceOperator = new ListExpressionOperator(); coalesceOperator.copyTo(clonedCoalesceOperator); ArgumentListFunctionExpression expression = new ArgumentListFunctionExpression(); expression.setBaseExpression(this); expression.setOperator(clonedCoalesceOperator); return expression; }
private static final ExpressionOperator createCoalesceOperator() { ListExpressionOperator operator = (ListExpressionOperator) ExpressionOperator.coalesce(); operator.setStartString("VALUE("); operator.setSelector(ExpressionOperator.Coalesce); return operator; }
/** * INTERNAL: * Print SQL */ public void printSQL(ExpressionSQLPrinter printer) { ListExpressionOperator platformOperator = (ListExpressionOperator)getPlatformOperator(printer.getPlatform()); platformOperator.copyTo(operator); ((ListExpressionOperator)operator).setIsComplete(true); operator.printCollection(getChildren(), printer); }
@Override protected void postCopyIn(Map alreadyDone) { ((ListExpressionOperator)operator).setNumberOfItems(0); Boolean hasLastChildCopy = hasLastChild; hasLastChild = null; super.postCopyIn(alreadyDone); hasLastChild = hasLastChildCopy; }
/** * INTERNAL: * Add a new Expression to the list of arguments. * This method will update the list of arguments and any constant strings that are required * to be printed with the arguments * @param argument */ @Override public synchronized void addChild(Expression argument){ if (hasLastChild != null && hasLastChild.booleanValue()){ getChildren().add(getChildren().size() - 1, argument); } else { super.addChild(argument); } setBaseExpression(getChildren().firstElement()); ((ListExpressionOperator)operator).incrementNumberOfItems(); }
/** * INTERNAL: * Build operator. * Note: This operator works differently from other operators. * @see Expression#caseStatement(Map, Object) */ public static ExpressionOperator caseStatement() { ListExpressionOperator exOperator = new ListExpressionOperator(); exOperator.setType(FunctionOperator); exOperator.setSelector(Case); exOperator.bePrefix(); exOperator.setNodeClass(ClassConstants.ArgumentListFunctionExpression_Class); exOperator.setIsBindingSupported(false); exOperator.setStartString("CASE "); exOperator.setSeparators(new String[]{" WHEN ", " THEN "}); exOperator.setTerminationStrings(new String[]{" ELSE ", " END"}); return exOperator; }
/** * INTERNAL: * Build operator. * Note: This operator works differently from other operators. * @see Expression#caseStatement(Map, Object) */ public static ExpressionOperator coalesce() { ListExpressionOperator exOperator = new ListExpressionOperator(); exOperator.setType(FunctionOperator); exOperator.setSelector(Coalesce); exOperator.bePrefix(); exOperator.setNodeClass(ClassConstants.ArgumentListFunctionExpression_Class); exOperator.setStartString("COALESCE("); exOperator.setSeparator(","); exOperator.setTerminationString(" )"); return exOperator; }
/** * INTERNAL: * Creates an ArgumentListFunctionExpression that is capable of creating a case statement of the form: * <blockquote><pre> * SQL: CASE name WHEN "Robert" THEN "Bob" * WHEN "Susan" THEN "Sue" * ELSE "No-Nickname" * </pre></blockquote> * * This expression must be manipulated to successfully build a case statement by adding appropriate * children to it. * * A child must be added for the "case expression" (name above), a pair of children must be added for * each "when then" expression and a child must be added for the else. * * @see ArgumentListFunctionExpression */ public ArgumentListFunctionExpression caseStatement() { ListExpressionOperator caseOperator = (ListExpressionOperator)getOperator(ExpressionOperator.Case); ListExpressionOperator clonedCaseOperator = new ListExpressionOperator(); caseOperator.copyTo(clonedCaseOperator); ArgumentListFunctionExpression expression = new ArgumentListFunctionExpression(); expression.setBaseExpression(this); expression.setOperator(clonedCaseOperator); return expression; }
/** * INTERNAL: */ public void initializePlatformOperator(DatabasePlatform platform) { super.initializePlatformOperator(platform); ((ListExpressionOperator)platformOperator).setNumberOfItems(((ListExpressionOperator)operator).getNumberOfItems()); }
@Override protected void postCopyIn(Map alreadyDone) { ((ListExpressionOperator)operator).setNumberOfItems(0); Boolean hasLastChildCopy = hasLastChild; hasLastChild = null; super.postCopyIn(alreadyDone); hasLastChild = hasLastChildCopy; } }