org.mule.transformers.xml
Class JXPathExtractor

java.lang.Object
  extended by org.mule.transformers.AbstractTransformer
      extended by org.mule.transformers.xml.JXPathExtractor
All Implemented Interfaces:
Cloneable, Initialisable, UMOBaseTransformer, UMOTransformer

public class JXPathExtractor
extends AbstractTransformer

The JXPathExtractor is a simple transformer that evaluates an xpath expression against the given bean and that returns the result.

By default, a single result will be returned. If multiple values are expected, set the singleResult property to false. In this case a List of values will be returned. Note the property is currently ignored for non-String/XML payloads.


Field Summary
 
Fields inherited from class org.mule.transformers.AbstractTransformer
DEFAULT_TRUNCATE_LENGTH, endpoint, logger, name, nextTransformer, returnClass, sourceTypes
 
Constructor Summary
JXPathExtractor()
           
 
Method Summary
 Object doTransform(Object src, String encoding)
          Evaluate the expression in the context of the given object and returns the result.
 String getExpression()
           
 boolean isSingleResult()
          Should a single value be returned.
 void setExpression(String expression)
           
 void setSingleResult(boolean singleResult)
          If multiple results are expected from the expression evaluation, set this to false.
 
Methods inherited from class org.mule.transformers.AbstractTransformer
checkReturnClass, clone, generateTransformerName, getEndpoint, getFinalReturnClass, getName, getNextTransformer, getReturnClass, initialise, isAcceptNull, isIgnoreBadInput, isSourceTypeSupported, isSourceTypeSupported, nextTransform, registerSourceType, setEndpoint, setIgnoreBadInput, setName, setNextTransformer, setReturnClass, toString, transform, unregisterSourceType
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JXPathExtractor

public JXPathExtractor()
Method Detail

doTransform

public Object doTransform(Object src,
                          String encoding)
                   throws TransformerException
Evaluate the expression in the context of the given object and returns the result. If the given object is a string, it assumes it is an valid xml and parses it before evaluating the xpath expression.

Specified by:
doTransform in class AbstractTransformer
Throws:
TransformerException

getExpression

public String getExpression()
Returns:
Returns the expression.

setExpression

public void setExpression(String expression)
Parameters:
expression - The expression to set.

isSingleResult

public boolean isSingleResult()
Should a single value be returned.

Returns:
value

setSingleResult

public void setSingleResult(boolean singleResult)
If multiple results are expected from the expression evaluation, set this to false.

Parameters:
singleResult - flag


Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.