throws FunctionEvaluationException
{
final CSSValue[] params = function.getParameters();
if (params.length < 2)
{
throw new FunctionEvaluationException("Illegal parameter count");
}
final CSSValue rawValue = FunctionUtilities.resolveParameter(layoutProcess, element, params[0]);
final String typeValue = FunctionUtilities.resolveString(layoutProcess, element, params[1]);
final LocalizationContext localizationContext =
DocumentContextUtility.getLocalizationContext
(layoutProcess.getDocumentContext());
final LayoutContext layoutContext = element.getLayoutContext();
if ("date".equals(typeValue))
{
if (params.length < 3)
{
return getDateValue(rawValue,
localizationContext.getDateFormat(layoutContext.getLanguage()));
}
else
{
final String format = FunctionUtilities.resolveString(layoutProcess, element, params[2]);
return getDateValue(rawValue,
localizationContext.getDateFormat(format, layoutContext.getLanguage()));
}
}
else if ("time".equals(typeValue))
{
if (params.length != 2)
{
throw new FunctionEvaluationException();
}
return getDateValue(rawValue,
localizationContext.getTimeFormat(layoutContext.getLanguage()));
}
else if ("number".equals(typeValue))
{
if (params.length < 3)
{
return getNumberValue(rawValue,
localizationContext.getDateFormat(layoutContext.getLanguage()));
}
else
{
final String format = FunctionUtilities.resolveString(layoutProcess, element, params[2]);
return getNumberValue(rawValue,
localizationContext.getNumberFormat(format, layoutContext.getLanguage()));
}
}
else if ("integer".equals(typeValue))
{
if (params.length != 2)
{
throw new FunctionEvaluationException();
}
return getNumberValue(rawValue,
localizationContext.getIntegerFormat(layoutContext.getLanguage()));
}
throw new FunctionEvaluationException("FormatType not recognized");
}