View Javadoc

1   /*
2    * $Id: BeanPayloadExpressionEvaluator.java 19191 2010-08-25 21:05:23Z tcarlson $
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  package org.mule.module.xml.expression;
11  
12  import org.jaxen.JaxenException;
13  import org.jaxen.XPath;
14  import org.jaxen.javabean.JavaBeanXPath;
15  
16  /** TODO */
17  public class BeanPayloadExpressionEvaluator extends AbstractXPathExpressionEvaluator
18  {
19      public static final String NAME = "bean";
20  
21      protected XPath createXPath(String expression, Object object) throws JaxenException
22      {
23          expression = expression.replaceAll("[.]", "/");
24          return new JavaBeanXPath(expression);
25      }
26  
27      protected Object extractResultFromNode(Object result)
28      {
29          if(result instanceof org.jaxen.javabean.Element)
30          {
31              return ((org.jaxen.javabean.Element)result).getObject();
32          }
33          return result;
34      }
35  
36      /** {@inheritDoc} */
37      public String getName()
38      {
39          return NAME;
40      }
41  }