throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_UNEXPECTED_VALUE);
}
if (s == null)
{
return new TypeValuePair(TextType.TYPE, "");
}
final String encodingResult;
if (parameterCount > 1)
{
final Object urlEncode = context.getTypeRegistry().convertToLogical(parameters.getType(1), parameters.getValue(1));
if (Boolean.FALSE.equals(urlEncode))
{
return new TypeValuePair(TextType.TYPE, s);
}
if(parameterCount == 3)
{
final Type encodingType = parameters.getType(2);
final Object encodingValue = parameters.getValue(2);
encodingResult = context.getTypeRegistry().convertToText(encodingType, encodingValue);
if(encodingResult == null)
{
throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
}
}
else
{
encodingResult = context.getConfiguration().getConfigProperty
("org.pentaho.reporting.libraries.formula.URLEncoding", "UTF-8");
}
}
else
{
encodingResult = context.getConfiguration().getConfigProperty
("org.pentaho.reporting.libraries.formula.URLEncoding", "UTF-8");
}
try
{
return new TypeValuePair(TextType.TYPE, URLEncoder.encode(s, encodingResult));
}
catch(final UnsupportedEncodingException use)
{
throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);