View Javadoc

1   /*
2    * $Id: MessageHeadersExpressionEvaluator.java 20321 2010-11-24 15:21:24Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.expression;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.expression.ExpressionEvaluator;
15  
16  import java.util.Map;
17  
18  /**
19   * Looks up the property on the message using the expression given. The expression can contain a comma-separated list
20   * of header names to lookup. A {@link java.util.Map} of key value pairs is returned.
21   *
22   * @see MessageHeadersListExpressionEvaluator
23   * @see org.mule.api.expression.ExpressionEvaluator
24   * @see DefaultExpressionManager
25   */
26  public class MessageHeadersExpressionEvaluator implements ExpressionEvaluator
27  {
28      public static final String NAME = "headers";
29  
30      public Object evaluate(String expression, MuleMessage message)
31      {
32          return ExpressionUtils.getPropertyWithScope(expression, message, Map.class);
33      }
34  
35      /**
36       * {@inheritDoc}
37       */
38      public String getName()
39      {
40          return NAME;
41      }
42  
43      /**
44       * {@inheritDoc}
45       */
46      public void setName(String name)
47      {
48          throw new UnsupportedOperationException();
49      }
50  }