/** * @see java.lang.Object#clone() */ public Object clone() { Expression expr = (Expression)expression.clone(); int whenCount = getWhenCount(); ArrayList whenCopy = new ArrayList(whenCount); ArrayList thenCopy = new ArrayList(whenCount); for(int i = 0; i < whenCount; i++) { whenCopy.add(getWhenExpression(i).clone()); thenCopy.add(getThenExpression(i).clone()); } Expression elseExpr = getElseExpression(); if (elseExpr != null) { elseExpr = (Expression)elseExpr.clone(); } CaseExpression copy = new CaseExpression(expr, whenCopy, thenCopy); copy.setType(getType()); copy.setElseExpression(elseExpr); return copy; }
/** * @see java.lang.Object#clone() */ public Object clone() { Expression expr = (Expression)expression.clone(); int whenCount = getWhenCount(); ArrayList whenCopy = new ArrayList(whenCount); ArrayList thenCopy = new ArrayList(whenCount); for(int i = 0; i < whenCount; i++) { whenCopy.add(getWhenExpression(i).clone()); thenCopy.add(getThenExpression(i).clone()); } Expression elseExpr = getElseExpression(); if (elseExpr != null) { elseExpr = (Expression)elseExpr.clone(); } CaseExpression copy = new CaseExpression(expr, whenCopy, thenCopy); copy.setType(getType()); copy.setElseExpression(elseExpr); return copy; }
/** * @see java.lang.Object#clone() */ public Object clone() { Expression expr = (Expression)expression.clone(); int whenCount = getWhenCount(); ArrayList whenCopy = new ArrayList(whenCount); ArrayList thenCopy = new ArrayList(whenCount); for(int i = 0; i < whenCount; i++) { whenCopy.add(getWhenExpression(i).clone()); thenCopy.add(getThenExpression(i).clone()); } Expression elseExpr = getElseExpression(); if (elseExpr != null) { elseExpr = (Expression)elseExpr.clone(); } CaseExpression copy = new CaseExpression(expr, whenCopy, thenCopy); copy.setType(getType()); copy.setElseExpression(elseExpr); return copy; }
@Test public void testCaseExpression1() { ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$ ElementSymbol y = new ElementSymbol("y"); //$NON-NLS-1$ Constant a = new Constant(String.valueOf('a')); Constant z = new Constant(String.valueOf('z')); HashMap<Expression, Expression> map = new HashMap<Expression, Expression>(); map.put(x, y); map.put(a, z); ArrayList<Expression> whens = new ArrayList<Expression>(), thens = new ArrayList<Expression>(); whens.add(new Constant(String.valueOf('z'))); thens.add(new Constant(new Integer(0))); whens.add(new Constant(String.valueOf('b'))); thens.add(new Constant(new Integer(1))); whens.add(new Constant(String.valueOf('c'))); thens.add(new Constant(new Integer(2))); CaseExpression mapped = new CaseExpression(y, whens, thens); mapped.setElseExpression(new Constant(new Integer(9999))); helpTest(TestCaseExpression.example(3), map, mapped); }
public static CaseExpression example(int whens) { ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$ CaseExpression caseExpr = new CaseExpression(x, getWhenExpressions(whens), getThenExpressions(whens)); caseExpr.setElseExpression(new Constant(new Integer(9999))); return caseExpr; }
CaseExpression caseExpr = new CaseExpression(expression, whenExpressions, thenExpressions); caseExpr.setElseExpression(elseExpression); {if (true) return caseExpr;}
CaseExpression caseExpr = new CaseExpression(expression, whenExpressions, thenExpressions); caseExpr.setElseExpression(elseExpression); {if (true) return caseExpr;}
CaseExpression caseExpr = new CaseExpression(expression, whenExpressions, thenExpressions); caseExpr.setElseExpression(elseExpression); {if (true) return caseExpr;}
public static CaseExpression example(int whens, int nullIndex, boolean includeNull) { ArgCheck.isTrue(nullIndex < whens, "Null Index must be less than the number of When expressions"); //$NON-NLS-1$ ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$ CaseExpression caseExpr = new CaseExpression(x, getWhenExpressions(whens, nullIndex, includeNull), getThenExpressions(whens)); caseExpr.setElseExpression(new Constant(new Integer(9999))); return caseExpr; }
thens.add(const2); Expression elseExpression = new Constant("c"); //$NON-NLS-1$ CaseExpression expr = new CaseExpression(x, whens, thens); expr.setElseExpression(elseExpression); expr.setType(DataTypeManager.DefaultDataClasses.STRING);