01: /*
02: * $Id: MessageHeaderExpressionEvaluator.java 11366 2008-03-14 11:48:22Z dirk.olmes $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.util.expression;
12:
13: import org.mule.api.transport.MessageAdapter;
14:
15: import java.util.HashMap;
16: import java.util.Map;
17: import java.util.StringTokenizer;
18:
19: /**
20: * Looks up the property on the message using the property name given.
21: *
22: * @see MessageHeadersListExpressionEvaluator
23: * @see MessageHeadersExpressionEvaluator
24: * @see ExpressionEvaluator
25: * @see ExpressionEvaluatorManager
26: */
27: public class MessageHeaderExpressionEvaluator implements
28: ExpressionEvaluator {
29: public static final String NAME = "header";
30:
31: public Object evaluate(String expression, Object message) {
32: if (message instanceof MessageAdapter) {
33: return ((MessageAdapter) message).getProperty(expression);
34: }
35: return null;
36: }
37:
38: /** {@inheritDoc} */
39: public String getName() {
40: return NAME;
41: }
42:
43: /** {@inheritDoc} */
44: public void setName(String name) {
45: throw new UnsupportedOperationException("setName");
46: }
47: }
|