required = false;
}
Object value = msg.getProperty(name, entryScope);
if (value == null && required)
{
throw new RequiredValueException(CoreMessages.expressionEvaluatorReturnedNull("headers", entryScope.getScopeName() + ":" + name));
}
else if (value != null)
{
props.put(name, value);
}
}
return (T) returnMap(props, scope);
}
else if (List.class.isAssignableFrom(type))
{
String[] names = expression.split(DELIM);
List<Object> values = new ArrayList<Object>();
for (String name : names)
{
boolean required = true;
name = name.trim();
PropertyScope itemScope = scope;
if (parseScope)
{
itemScope = getScope(name);
if (itemScope != null)
{
// cut-off leading scope and separator
name = name.substring(itemScope.getScopeName().length() + 1);
}
else
{
itemScope = scope;
}
}
if (name.endsWith(OPTIONAL_ARGUMENT))
{
name = name.substring(0, name.length() - OPTIONAL_ARGUMENT.length());
required = false;
}
name = name.trim();
Object value = msg.getProperty(name, itemScope);
if (value == null && required)
{
throw new RequiredValueException(CoreMessages.expressionEvaluatorReturnedNull("headers-list", itemScope.getScopeName() + ":" + name));
}
else if (value != null)
{
values.add(value);
}
}
return (T) returnList(values, scope);
}
else
{
boolean required = true;
if (expression.endsWith(OPTIONAL_ARGUMENT))
{
expression = expression.substring(0, expression.length() - OPTIONAL_ARGUMENT.length());
required = false;
}
Object result = msg.getProperty(expression.trim(), scope);
if (result == null && required)
{
throw new RequiredValueException(CoreMessages.expressionEvaluatorReturnedNull("header", scope.getScopeName() + ":" + expression));
}
return (T) result;
}
}