protected Value execute(
ExpressionContext expressionContext,
MarinerRequestContext requestContext, String name,
Value defaultValue) {
ExpressionFactory factory = expressionContext.getFactory();
Value value = defaultValue;
EnvironmentContext environmentContext =
ContextInternals.getEnvironmentContext(requestContext);
// See if the header can be found
Enumeration enumeration = environmentContext.getHeaders(name);
// The number of headers isn't known until the enumeration has
// been traversed so build up a dynamic array of the header
// values
List headers;
if (enumeration == null || !enumeration.hasMoreElements()) {
headers = Collections.EMPTY_LIST;
} else {
headers = new ArrayList();
// Add each header, as a string value, to an array
while (enumeration.hasMoreElements()) {
headers.add(enumeration.nextElement());
}
int count = headers.size();
// One or more header values were found so put them in
// a sequence
Item[] items = new Item[count];
for (int i = 0; i < count; i++) {
String string = (String) headers.get(i);
items[i] = factory.createStringValue(string);
}
value = factory.createSequence(items);
}
// Add dependency information if necessary.
DependencyContext context = expressionContext.getDependencyContext();
if (context.isTrackingDependencies()) {