final ParameterCallback parameters) throws EvaluationException
{
final int parameterCount = parameters.getParameterCount();
if (parameterCount != 4)
{
throw new EvaluationException(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
}
final TypeRegistry typeRegistry = context.getTypeRegistry();
final Type newTextType = parameters.getType(3);
final Object newTextValue = parameters.getValue(3);
final Type textType = parameters.getType(0);
final Object textValue = parameters.getValue(0);
final Type startType = parameters.getType(1);
final Object startValue = parameters.getValue(1);
final Type lengthType = parameters.getType(2);
final Object lengthValue = parameters.getValue(2);
final String newText = typeRegistry.convertToText(newTextType, newTextValue);
final String text = typeRegistry.convertToText(textType, textValue);
final Number start = typeRegistry.convertToNumber(startType, startValue);
if (start.intValue() <= 0)
{
throw new EvaluationException(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
}
final Number length = typeRegistry.convertToNumber(lengthType, lengthValue);
if (length.intValue() < 0)
{
throw new EvaluationException(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
}
final String result1 = MidFunction.process(text, 1, (start.intValue() - 1));
final String result2 = MidFunction.process(text, (start.intValue() + length.intValue()), (text.length()));