org.apache.servicemix.expression
Class JAXPXPathExpression

java.lang.Object
  extended by org.apache.servicemix.expression.JAXPXPathExpression
All Implemented Interfaces:
Expression, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
JAXPBooleanXPathExpression, JAXPNodeSetXPathExpression, JAXPStringXPathExpression, JAXPXPathXStreamExpression

public class JAXPXPathExpression
extends java.lang.Object
implements Expression, org.springframework.beans.factory.InitializingBean

Evalutes an XPath expression on the given message using JAXP

Version:
$Revision: 654087 $

Constructor Summary
JAXPXPathExpression()
           
JAXPXPathExpression(java.lang.String xpath)
          A helper constructor to make a fully created expression.
 
Method Summary
 void afterPropertiesSet()
          Compiles the xpath expression.
 void enableContentRereadability(javax.jbi.messaging.NormalizedMessage message)
          Convert the given NormalizedMessage instance's content to a re-readable Source This allows the content to be read more than once (e.g.
 java.lang.Object evaluate(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage message)
          Evaluates the XPath expression and returns the string values for the XML items described by that expression.
 java.lang.Object evaluate(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage message, javax.xml.namespace.QName returnType)
          Evaluates the XPath expression and the XML items described by that expression.
protected  java.lang.Object evaluateXPath(java.lang.Object object)
           
protected  java.lang.Object evaluateXPath(java.lang.Object object, javax.xml.namespace.QName returnType)
           
 javax.xml.xpath.XPathFactory getFactory()
           
 javax.xml.xpath.XPathFunctionResolver getFunctionResolver()
           
 javax.xml.namespace.NamespaceContext getNamespaceContext()
           
 SourceTransformer getTransformer()
           
 MessageVariableResolver getVariableResolver()
           
protected  java.lang.Object getXMLNode(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage message)
           
 java.lang.String getXPath()
           
protected  javax.xml.xpath.XPathExpression getXPathExpression()
           
 boolean isUseMessageContent()
           
 void setFactory(javax.xml.xpath.XPathFactory factory)
           
 void setFunctionResolver(javax.xml.xpath.XPathFunctionResolver functionResolver)
           
 void setNamespaceContext(javax.xml.namespace.NamespaceContext namespaceContext)
           
 void setTransformer(SourceTransformer transformer)
           
 void setUseMessageContent(boolean useMessageContent)
          Specifies whether or not the XPath expression uses the message content.
 void setVariableResolver(MessageVariableResolver variableResolver)
           
 void setXPath(java.lang.String xp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JAXPXPathExpression

public JAXPXPathExpression()

JAXPXPathExpression

public JAXPXPathExpression(java.lang.String xpath)
A helper constructor to make a fully created expression.

Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws javax.xml.xpath.XPathExpressionException
Compiles the xpath expression.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
javax.xml.xpath.XPathExpressionException

evaluate

public java.lang.Object evaluate(javax.jbi.messaging.MessageExchange exchange,
                                 javax.jbi.messaging.NormalizedMessage message)
                          throws javax.jbi.messaging.MessagingException
Evaluates the XPath expression and returns the string values for the XML items described by that expression. Before evaluating the xpath expression, it will be compiled by calling the afterPropertiesSet() method.

Specified by:
evaluate in interface Expression
Parameters:
exchange - MessageExchange to use on MessageVariableResolver
message - NormalizedMessage to use on MessageVariableResolver
Returns:
Object Contains the string values for the XML items described by the provided XPath expression
Throws:
javax.jbi.messaging.MessagingException

evaluate

public java.lang.Object evaluate(javax.jbi.messaging.MessageExchange exchange,
                                 javax.jbi.messaging.NormalizedMessage message,
                                 javax.xml.namespace.QName returnType)
                          throws javax.jbi.messaging.MessagingException
Evaluates the XPath expression and the XML items described by that expression. The type is determined by the returnType parameter. Before evaluating the xpath expression, it will be compiled by calling the afterPropertiesSet() method.

Parameters:
exchange - MessageExchange to use on MessageVariableResolver
message - NormalizedMessage to use on MessageVariableResolver
returnType - QName as defined by javax.xml.xpath.XPathConstants that describes the desired type of the object to be retuned
Returns:
Object Contains the XML items described by the provided XPath expression. The type is determined by the returnType parameter.
Throws:
javax.jbi.messaging.MessagingException

getXPath

public java.lang.String getXPath()

setXPath

public void setXPath(java.lang.String xp)

isUseMessageContent

public boolean isUseMessageContent()

setUseMessageContent

public void setUseMessageContent(boolean useMessageContent)
Specifies whether or not the XPath expression uses the message content. By default, this property is true, but you can set it to false to avoid that the message content is converted to StringSource

Parameters:
useMessageContent - specify false if this expression does not access the message content

getTransformer

public SourceTransformer getTransformer()

setTransformer

public void setTransformer(SourceTransformer transformer)

getVariableResolver

public MessageVariableResolver getVariableResolver()

setVariableResolver

public void setVariableResolver(MessageVariableResolver variableResolver)

getFactory

public javax.xml.xpath.XPathFactory getFactory()

setFactory

public void setFactory(javax.xml.xpath.XPathFactory factory)

getFunctionResolver

public javax.xml.xpath.XPathFunctionResolver getFunctionResolver()

setFunctionResolver

public void setFunctionResolver(javax.xml.xpath.XPathFunctionResolver functionResolver)

getNamespaceContext

public javax.xml.namespace.NamespaceContext getNamespaceContext()

setNamespaceContext

public void setNamespaceContext(javax.xml.namespace.NamespaceContext namespaceContext)

evaluateXPath

protected java.lang.Object evaluateXPath(java.lang.Object object)
                                  throws javax.xml.xpath.XPathExpressionException
Throws:
javax.xml.xpath.XPathExpressionException

evaluateXPath

protected java.lang.Object evaluateXPath(java.lang.Object object,
                                         javax.xml.namespace.QName returnType)
                                  throws javax.xml.xpath.XPathExpressionException
Throws:
javax.xml.xpath.XPathExpressionException

getXPathExpression

protected javax.xml.xpath.XPathExpression getXPathExpression()

getXMLNode

protected java.lang.Object getXMLNode(javax.jbi.messaging.MessageExchange exchange,
                                      javax.jbi.messaging.NormalizedMessage message)
                               throws javax.xml.transform.TransformerException,
                                      javax.jbi.messaging.MessagingException,
                                      javax.xml.parsers.ParserConfigurationException,
                                      java.io.IOException,
                                      org.xml.sax.SAXException
Throws:
javax.xml.transform.TransformerException
javax.jbi.messaging.MessagingException
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException

enableContentRereadability

public void enableContentRereadability(javax.jbi.messaging.NormalizedMessage message)
                                throws javax.jbi.messaging.MessagingException
Convert the given NormalizedMessage instance's content to a re-readable Source This allows the content to be read more than once (e.g. for XPath evaluation or auditing).

Parameters:
message - the NormalizedMessage to convert the content for
Throws:
javax.jbi.messaging.MessagingException


Copyright © 2005-2011 Apache Software Foundation. All Rights Reserved.