View Javadoc

1   /*
2    * $Id: MessageHeaderExpressionEvaluator.java 11433 2008-03-20 03:43:57Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.util.expression;
12  
13  import org.mule.api.transport.MessageAdapter;
14  
15  /**
16   * Looks up the property on the message using the property name given.
17   *
18   * @see MessageHeadersListExpressionEvaluator
19   * @see MessageHeadersExpressionEvaluator
20   * @see ExpressionEvaluator
21   * @see ExpressionEvaluatorManager
22   */
23  public class MessageHeaderExpressionEvaluator implements ExpressionEvaluator
24  {
25      public static final String NAME = "header";
26  
27      public Object evaluate(String expression, Object message)
28      {
29          if (message instanceof MessageAdapter)
30          {
31              return ((MessageAdapter) message).getProperty(expression);
32          }
33          return null;
34      }
35  
36      /** {@inheritDoc} */
37      public String getName()
38      {
39          return NAME;
40      }
41  
42      /** {@inheritDoc} */
43      public void setName(String name)
44      {
45          throw new UnsupportedOperationException("setName");
46      }
47  }