Class XPathTransformer

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.transformer.AbstractTransformer
org.springframework.integration.xml.transformer.XPathTransformer
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.integration.context.ExpressionCapable, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.transformer.GenericTransformer<org.springframework.messaging.Message<?>,​org.springframework.messaging.Message<?>>, org.springframework.integration.transformer.Transformer

public class XPathTransformer
extends org.springframework.integration.transformer.AbstractTransformer
Transformer implementation that evaluates an XPath expression against the inbound Message payload and returns a Message whose payload is the result of that evaluation. Prior to evaluation, the payload may be converted by the configured XmlPayloadConverter instance. The default converter type is DefaultXmlPayloadConverter.

The evaluation result type will depend on either the enumeration value provided to setEvaluationType(XPathEvaluationType) or the presence of a NodeMapper, which takes precedence. If no NodeMapper or evaluation type is configured explicitly, the default evaluation type is XPathEvaluationType.STRING_RESULT.

Since:
2.0
  • Field Summary

    Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport

    EXPRESSION_PARSER, logger
  • Constructor Summary

    Constructors 
    Constructor Description
    XPathTransformer​(java.lang.String expression)
    Create an XPathTransformer that will create an XPath expression from the given String to be evaluated against converted inbound Message payloads.
    XPathTransformer​(org.springframework.xml.xpath.XPathExpression expression)
    Create an XPathTransformer that will evaluate the given XPathExpression against converted inbound Message payloads.
  • Method Summary

    Modifier and Type Method Description
    protected java.lang.Object doTransform​(org.springframework.messaging.Message<?> message)  
    java.lang.String getComponentType()  
    void setConverter​(XmlPayloadConverter converter)
    Specify the XmlPayloadConverter to use when converting a Message payload prior to XPath evaluation.
    void setEvaluationType​(XPathEvaluationType evaluationType)
    Specify the expected XPathEvaluationType.
    void setNodeMapper​(org.springframework.xml.xpath.NodeMapper<?> nodeMapper)
    Set a NodeMapper to use for generating the result object.

    Methods inherited from class org.springframework.integration.transformer.AbstractTransformer

    transform

    Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport

    afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, onInit, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • XPathTransformer

      public XPathTransformer​(java.lang.String expression)
      Create an XPathTransformer that will create an XPath expression from the given String to be evaluated against converted inbound Message payloads.
      Parameters:
      expression - The expression.
    • XPathTransformer

      public XPathTransformer​(org.springframework.xml.xpath.XPathExpression expression)
      Create an XPathTransformer that will evaluate the given XPathExpression against converted inbound Message payloads.
      Parameters:
      expression - The expression.
  • Method Details

    • setEvaluationType

      public void setEvaluationType​(XPathEvaluationType evaluationType)
      Specify the expected XPathEvaluationType. The default is XPathEvaluationType.STRING_RESULT.
      Parameters:
      evaluationType - The evaluation type.
    • setNodeMapper

      public void setNodeMapper​(org.springframework.xml.xpath.NodeMapper<?> nodeMapper)
      Set a NodeMapper to use for generating the result object. By default the NodeMapper is null, but if explicitly set, type determination is the responsibility of the NodeMapper, taking precedence over any configured evaluationType.
      Parameters:
      nodeMapper - The node mapper.
    • setConverter

      public void setConverter​(XmlPayloadConverter converter)
      Specify the XmlPayloadConverter to use when converting a Message payload prior to XPath evaluation.
      Parameters:
      converter - The payload converter.
    • getComponentType

      public java.lang.String getComponentType()
      Specified by:
      getComponentType in interface org.springframework.integration.support.context.NamedComponent
      Overrides:
      getComponentType in class org.springframework.integration.context.IntegrationObjectSupport
    • doTransform

      protected java.lang.Object doTransform​(org.springframework.messaging.Message<?> message)
      Specified by:
      doTransform in class org.springframework.integration.transformer.AbstractTransformer