public ValueEval evaluate( int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1, ValueEval arg2) { String result; try { String oldStr = TextFunction.evaluateStringArg(arg0, srcRowIndex, srcColumnIndex); String searchStr = TextFunction.evaluateStringArg(arg1, srcRowIndex, srcColumnIndex); String newStr = TextFunction.evaluateStringArg(arg2, srcRowIndex, srcColumnIndex); result = replaceAllOccurrences(oldStr, searchStr, newStr); } catch (EvaluationException e) { return e.getErrorEval(); } return new StringEval(result); }
public ValueEval evaluate( int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1, ValueEval arg2, ValueEval arg3) { String result; try { String oldStr = TextFunction.evaluateStringArg(arg0, srcRowIndex, srcColumnIndex); String searchStr = TextFunction.evaluateStringArg(arg1, srcRowIndex, srcColumnIndex); String newStr = TextFunction.evaluateStringArg(arg2, srcRowIndex, srcColumnIndex); int instanceNumber = TextFunction.evaluateIntArg(arg3, srcRowIndex, srcColumnIndex); if (instanceNumber < 1) { return ErrorEval.VALUE_INVALID; } result = replaceOneOccurrence(oldStr, searchStr, newStr, instanceNumber); } catch (EvaluationException e) { return e.getErrorEval(); } return new StringEval(result); }