org.apache.camel.builder.xpath
Class XPathBuilder<E extends Exchange>

java.lang.Object
  extended by org.apache.camel.builder.xpath.XPathBuilder<E>
All Implemented Interfaces:
Expression<E>, Predicate<E>

public class XPathBuilder<E extends Exchange>
extends Object
implements Expression<E>, Predicate<E>

Creates an XPath expression builder

Version:
$Revision: 531854 $

Constructor Summary
XPathBuilder(String text)
           
 
Method Summary
 void assertMatches(String text, E exchange)
          Allows this predicate to be used nicely in testing to generate a nicely formatted exception and message if this predicate does not match for the given exchange.
 XPathBuilder<E> booleanResult()
          Sets the expression result type to boolean
protected  XPathExpression createXPathExpression()
           
 Object evaluate(E exchange)
          Returns the value of the expression on the given exchange
protected  Object evaluateAs(E exchange, QName resultType)
          Evaluates the expression as the given result type
 XPathBuilder<E> functionResolver(XPathFunctionResolver functionResolver)
          Sets the XPathFunctionResolver instance to use on these XPath expressions
protected  Object getDocument(E exchange)
          Strategy method to extract the document from the exchange
 Class getDocumentType()
           
 XPathExpression getExpression()
           
 XPathFunctionResolver getFunctionResolver()
           
 DefaultNamespaceContext getNamespaceContext()
           
 QName getResultType()
           
 String getText()
           
 XPathFactory getXPathFactory()
           
 boolean matches(E exchange)
          Evaluates the predicate on the message exchange and returns true if this exchange matches the predicate
 XPathBuilder<E> namespace(String prefix, String uri)
          Registers the namespace prefix and URI with the builder so that the prefix can be used in XPath expressions
 XPathBuilder<E> nodeResult()
          Sets the expression result type to boolean
 XPathBuilder<E> nodeSetResult()
          Sets the expression result type to boolean
 XPathBuilder<E> numberResult()
          Sets the expression result type to boolean
 XPathBuilder<E> objectModel(String uri)
          Sets the object model URI to use
 void setDocumentType(Class documentType)
           
 void setFunctionResolver(XPathFunctionResolver functionResolver)
           
 void setNamespaceContext(DefaultNamespaceContext namespaceContext)
           
 void setXPathFactory(XPathFactory xpathFactory)
           
 XPathBuilder<E> stringResult()
          Sets the expression result type to boolean
 String toString()
           
 XPathBuilder<E> variable(String name, Object value)
          Registers a variable (in the global namespace) which can be referred to from XPath expressions
static XPathBuilder xpath(String text)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XPathBuilder

public XPathBuilder(String text)
Method Detail

xpath

public static XPathBuilder xpath(String text)

toString

public String toString()
Overrides:
toString in class Object

matches

public boolean matches(E exchange)
Description copied from interface: Predicate
Evaluates the predicate on the message exchange and returns true if this exchange matches the predicate

Specified by:
matches in interface Predicate<E extends Exchange>
Parameters:
exchange - the message exchange
Returns:
true if the predicate matches

assertMatches

public void assertMatches(String text,
                          E exchange)
                   throws AssertionError
Description copied from interface: Predicate
Allows this predicate to be used nicely in testing to generate a nicely formatted exception and message if this predicate does not match for the given exchange.

Specified by:
assertMatches in interface Predicate<E extends Exchange>
Parameters:
text - the description to use in the exception message
exchange - the exchange to evaluate the expression on
Throws:
AssertionError - if the predicate does not match

evaluate

public Object evaluate(E exchange)
Description copied from interface: Expression
Returns the value of the expression on the given exchange

Specified by:
evaluate in interface Expression<E extends Exchange>
Parameters:
exchange - the message exchange on which to evaluate the expression
Returns:
the value of the expression

booleanResult

public XPathBuilder<E> booleanResult()
Sets the expression result type to boolean

Returns:
the current builder

nodeResult

public XPathBuilder<E> nodeResult()
Sets the expression result type to boolean

Returns:
the current builder

nodeSetResult

public XPathBuilder<E> nodeSetResult()
Sets the expression result type to boolean

Returns:
the current builder

numberResult

public XPathBuilder<E> numberResult()
Sets the expression result type to boolean

Returns:
the current builder

stringResult

public XPathBuilder<E> stringResult()
Sets the expression result type to boolean

Returns:
the current builder

objectModel

public XPathBuilder<E> objectModel(String uri)
Sets the object model URI to use

Returns:
the current builder

functionResolver

public XPathBuilder<E> functionResolver(XPathFunctionResolver functionResolver)
Sets the XPathFunctionResolver instance to use on these XPath expressions

Returns:
the current builder

namespace

public XPathBuilder<E> namespace(String prefix,
                                 String uri)
Registers the namespace prefix and URI with the builder so that the prefix can be used in XPath expressions

Parameters:
prefix - is the namespace prefix that can be used in the XPath expressions
uri - is the namespace URI to which the prefix refers
Returns:
the current builder

variable

public XPathBuilder<E> variable(String name,
                                Object value)
Registers a variable (in the global namespace) which can be referred to from XPath expressions


getXPathFactory

public XPathFactory getXPathFactory()
                             throws XPathFactoryConfigurationException
Throws:
XPathFactoryConfigurationException

setXPathFactory

public void setXPathFactory(XPathFactory xpathFactory)

getDocumentType

public Class getDocumentType()

setDocumentType

public void setDocumentType(Class documentType)

getText

public String getText()

getResultType

public QName getResultType()

getNamespaceContext

public DefaultNamespaceContext getNamespaceContext()

setNamespaceContext

public void setNamespaceContext(DefaultNamespaceContext namespaceContext)

getFunctionResolver

public XPathFunctionResolver getFunctionResolver()

setFunctionResolver

public void setFunctionResolver(XPathFunctionResolver functionResolver)

getExpression

public XPathExpression getExpression()
                              throws XPathFactoryConfigurationException,
                                     XPathExpressionException
Throws:
XPathFactoryConfigurationException
XPathExpressionException

evaluateAs

protected Object evaluateAs(E exchange,
                            QName resultType)
Evaluates the expression as the given result type


createXPathExpression

protected XPathExpression createXPathExpression()
                                         throws XPathExpressionException,
                                                XPathFactoryConfigurationException
Throws:
XPathExpressionException
XPathFactoryConfigurationException

getDocument

protected Object getDocument(E exchange)
Strategy method to extract the document from the exchange



Copyright © 2007 Apache Software Foundation. All Rights Reserved.