{
// we expect strings and will check, whether the reference for theses
// strings is dirty.
if (context instanceof ReportFormulaContext == false)
{
return new TypeValuePair(ErrorType.TYPE, new LibFormulaErrorValue
(LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE));
}
final ReportFormulaContext reportFormulaContext =
(ReportFormulaContext) context;
final Object declaringElement = reportFormulaContext.getDeclaringElement();
if (declaringElement instanceof Element == false)
{
return new TypeValuePair(ErrorType.TYPE, new LibFormulaErrorValue
(LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE));
}
final Element element = (Element) declaringElement;
if (parameters.getParameterCount() == 1)
{
final String value = (String) parameters.getValue(0);
return new TypeValuePair(AnyType.TYPE, element.getAttribute(value));
}
else if (parameters.getParameterCount() == 2)
{
final String namespace = (String) parameters.getValue(0);
final String attrName = (String) parameters.getValue(1);
return new TypeValuePair(AnyType.TYPE,
element.getAttribute(namespace, attrName));
}
return new TypeValuePair(ErrorType.TYPE, new LibFormulaErrorValue
(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT));
}