final SIRFilter filter = (SIRFilter)pipe.get(0);   RenameAll.renameFilterContents(filter);    if (pipe.getInit()!=null) { pipe.getInit().addStatement( new JExpressionStatement(null, new JMethodCallExpression(null, new JThisExpression(null), filter.getInit().getName(), (JExpression[])pipe.getParams(pipe.indexOf(filter)).toArray(new JExpression[0])), null)); filter.setInitWithoutReplacement(pipe.getInit()); }   filter.addFields(pipe.getFields()); filter.addMethods(pipe.getMethods());  SIRContainer parent = pipe.getParent();  parent.replace(pipe, filter);  return true;
    public static boolean eliminatePipe(final SIRPipeline pipe) {	// if pipe is down to a single filter and we're not at the	// toplevel already, then eliminate the pipeline	if (!(pipe.size()==1 && 	      pipe.get(0) instanceof SIRFilter &&	      pipe.getParent()!=null)) {	    return false;	}	// find the filter of interest	final SIRFilter filter = (SIRFilter)pipe.get(0);	// rename the contents of <filter>	RenameAll.renameFilterContents(filter);	// add a method call to filter's <init> from <pipe's> init	// function 	if (pipe.getInit()!=null) {	    pipe.getInit().addStatement(		    new JExpressionStatement(null,			     new JMethodCallExpression(null, 			     new JThisExpression(null),			     filter.getInit().getName(),			     (JExpression[])pipe.getParams(pipe.indexOf(filter)).toArray(new JExpression[0])),				     null));	    filter.setInitWithoutReplacement(pipe.getInit());	}	// add all the methods and fields of <pipe> to <filter>	filter.addFields(pipe.getFields());	filter.addMethods(pipe.getMethods());	SIRContainer parent = pipe.getParent();	// in parent, replace <pipe> with <filter>	parent.replace(pipe, filter);		return true;    }