* @param exprFilter
*/
private ME replaceNullNode(Expression exprFilter) throws SpeedoException {
ME me = null;
if ((exprFilter instanceof Equal) || (exprFilter instanceof NotEqual)){
Operator op = (Operator) exprFilter;
for (int i = 0; i < op.getOperandNumber(); i++) {
if (op.getExpression(i) instanceof DummyOperand) {
//get the other child operand
int j = (i+1) % 2;
Expression other = op.getExpression(j);
PType ptype = other.getType();
if (ptype.getTypeCode() == PType.TYPECODE_REFERENCE) {
PName val = null;
try {
val = jf.getPClassMapping(ptype.getJormName(), clazz.getClassLoader()).getPBinder().getNull();
} catch (Exception e) {
throw new SpeedoException(
"Try to replace null node. Impossible to find the null PName for the type " + ptype.getJormName(), e);
}
//replace the null node with null PName
op.setExpression(i, new BasicOperand(val, ptype));
} else {
//Transform the null [not]equality into a IsNull operator
me = new ME(new IsNull(other, exprFilter instanceof NotEqual));
//recursion is done on the other operand
exprFilter = me.e;
}
}
}
}
if (exprFilter instanceof Operator) {
Operator op = (Operator) exprFilter;
for (int i = 0; i < op.getOperandNumber(); i++) {
//recursivity
ME ime = replaceNullNode(op.getExpression(i));
if (ime != null && ime.modified) {
//replace the child
op.setExpression(i, ime.e);
//mark the result as modified
if (me == null) {//create if not already done
me = new ME(exprFilter);
}
me.modified = true;