org.apache.camel.component.xquery
Class XQueryBuilder

java.lang.Object
  extended by org.apache.camel.component.xquery.XQueryBuilder
All Implemented Interfaces:
Expression, Predicate, Processor, NamespaceAware

public abstract class XQueryBuilder
extends Object
implements Expression, Predicate, NamespaceAware, Processor

Creates an XQuery builder

Version:
$Revision: 16337 $

Constructor Summary
XQueryBuilder()
           
 
Method Summary
protected  void addParameters(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext, Map<String,Object> map)
           
protected  void addParameters(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext, Map<String,Object> map, String parameterPrefix)
           
 XQueryBuilder asBytes()
           
 XQueryBuilder asBytesSource()
           
 XQueryBuilder asDOM()
           
 XQueryBuilder asDOMSource()
           
 XQueryBuilder asList()
           
 void assertMatches(String text, Exchange exchange)
           
 XQueryBuilder asString()
           
 XQueryBuilder asStringSource()
           
protected  void configureQuery(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext, Exchange exchange)
          Configures the dynamic context with exchange specific parameters
protected  net.sf.saxon.query.DynamicQueryContext createDynamicContext(Exchange exchange)
          Creates a dynamic context for the given exchange
protected abstract  net.sf.saxon.query.XQueryExpression createQueryExpression(net.sf.saxon.query.StaticQueryContext staticQueryContext)
          A factory method to create the XQuery expression
 Object evaluate(Exchange exchange)
           
<T> T
evaluate(Exchange exchange, Class<T> type)
          Returns the value of the expression on the given exchange
 byte[] evaluateAsBytes(Exchange exchange)
           
 Object evaluateAsBytesSource(Exchange exchange)
           
 Node evaluateAsDOM(Exchange exchange)
           
 List evaluateAsList(Exchange exchange)
           
 String evaluateAsString(Exchange exchange)
           
 Object evaluateAsStringSource(Exchange exchange)
           
 net.sf.saxon.Configuration getConfiguration()
           
 net.sf.saxon.query.XQueryExpression getExpression()
           
 Map<String,Object> getParameters()
           
 Properties getProperties()
           
 ResultFormat getResultsFormat()
           
 Class getResultType()
           
 net.sf.saxon.query.StaticQueryContext getStaticQueryContext()
           
protected  void initialize(Exchange exchange)
          Initializes this builder - Must be invoked before evaluation.
 boolean matches(Exchange exchange)
          Evaluates the predicate on the message exchange and returns true if this exchange matches the predicate
protected  boolean matches(Exchange exchange, List results)
           
 XQueryBuilder namespace(String prefix, String uri)
           
 XQueryBuilder parameter(String name, Object value)
           
 void process(Exchange exchange)
          Processes the message exchange
 XQueryBuilder resultType(Class resultType)
           
 void setConfiguration(net.sf.saxon.Configuration configuration)
           
 void setNamespaces(Map<String,String> namespaces)
          Configures the namespace context from the given DOM element
 void setParameters(Map<String,Object> parameters)
           
 void setProperties(Properties properties)
           
 void setResultsFormat(ResultFormat resultsFormat)
           
 void setResultType(Class resultType)
           
 void setStaticQueryContext(net.sf.saxon.query.StaticQueryContext staticQueryContext)
           
 String toString()
           
static XQueryBuilder xquery(File file)
           
static XQueryBuilder xquery(File file, String characterSet)
           
static XQueryBuilder xquery(InputStream in, String characterSet)
           
static XQueryBuilder xquery(Reader reader)
           
static XQueryBuilder xquery(String queryText)
           
static XQueryBuilder xquery(URL url)
           
static XQueryBuilder xquery(URL url, String characterSet)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XQueryBuilder

public XQueryBuilder()
Method Detail

toString

public String toString()
Overrides:
toString in class Object

process

public void process(Exchange exchange)
             throws Exception
Description copied from interface: Processor
Processes the message exchange

Specified by:
process in interface Processor
Parameters:
exchange - the message exchange
Throws:
Exception - if an internal processing error has occurred.

evaluate

public <T> T evaluate(Exchange exchange,
                      Class<T> type)
Description copied from interface: Expression
Returns the value of the expression on the given exchange

Specified by:
evaluate in interface Expression
Parameters:
exchange - the message exchange on which to evaluate the expression
type - the expected type of the evaluation result
Returns:
the value of the expression

evaluate

public Object evaluate(Exchange exchange)

evaluateAsList

public List evaluateAsList(Exchange exchange)
                    throws Exception
Throws:
Exception

evaluateAsStringSource

public Object evaluateAsStringSource(Exchange exchange)
                              throws Exception
Throws:
Exception

evaluateAsBytesSource

public Object evaluateAsBytesSource(Exchange exchange)
                             throws Exception
Throws:
Exception

evaluateAsDOM

public Node evaluateAsDOM(Exchange exchange)
                   throws Exception
Throws:
Exception

evaluateAsBytes

public byte[] evaluateAsBytes(Exchange exchange)
                       throws Exception
Throws:
Exception

evaluateAsString

public String evaluateAsString(Exchange exchange)
                        throws Exception
Throws:
Exception

matches

public boolean matches(Exchange 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
Parameters:
exchange - the message exchange
Returns:
true if the predicate matches

assertMatches

public void assertMatches(String text,
                          Exchange exchange)
                   throws AssertionError
Throws:
AssertionError

xquery

public static XQueryBuilder xquery(String queryText)

xquery

public static XQueryBuilder xquery(Reader reader)

xquery

public static XQueryBuilder xquery(InputStream in,
                                   String characterSet)

xquery

public static XQueryBuilder xquery(File file,
                                   String characterSet)
                            throws IOException
Throws:
IOException

xquery

public static XQueryBuilder xquery(URL url,
                                   String characterSet)
                            throws IOException
Throws:
IOException

xquery

public static XQueryBuilder xquery(File file)
                            throws IOException
Throws:
IOException

xquery

public static XQueryBuilder xquery(URL url)
                            throws IOException
Throws:
IOException

parameter

public XQueryBuilder parameter(String name,
                               Object value)

namespace

public XQueryBuilder namespace(String prefix,
                               String uri)

resultType

public XQueryBuilder resultType(Class resultType)

asBytes

public XQueryBuilder asBytes()

asBytesSource

public XQueryBuilder asBytesSource()

asDOM

public XQueryBuilder asDOM()

asDOMSource

public XQueryBuilder asDOMSource()

asList

public XQueryBuilder asList()

asString

public XQueryBuilder asString()

asStringSource

public XQueryBuilder asStringSource()

setNamespaces

public void setNamespaces(Map<String,String> namespaces)
Configures the namespace context from the given DOM element

Specified by:
setNamespaces in interface NamespaceAware
Parameters:
namespaces - the XML namespaces with the key of prefixes and the value the URIs

getExpression

public net.sf.saxon.query.XQueryExpression getExpression()
                                                  throws IOException,
                                                         net.sf.saxon.trans.XPathException
Throws:
IOException
net.sf.saxon.trans.XPathException

getConfiguration

public net.sf.saxon.Configuration getConfiguration()

setConfiguration

public void setConfiguration(net.sf.saxon.Configuration configuration)

getStaticQueryContext

public net.sf.saxon.query.StaticQueryContext getStaticQueryContext()
                                                            throws net.sf.saxon.trans.XPathException
Throws:
net.sf.saxon.trans.XPathException

setStaticQueryContext

public void setStaticQueryContext(net.sf.saxon.query.StaticQueryContext staticQueryContext)

getParameters

public Map<String,Object> getParameters()

setParameters

public void setParameters(Map<String,Object> parameters)

getProperties

public Properties getProperties()

setProperties

public void setProperties(Properties properties)

getResultsFormat

public ResultFormat getResultsFormat()

setResultsFormat

public void setResultsFormat(ResultFormat resultsFormat)

getResultType

public Class getResultType()

setResultType

public void setResultType(Class resultType)

createQueryExpression

protected abstract net.sf.saxon.query.XQueryExpression createQueryExpression(net.sf.saxon.query.StaticQueryContext staticQueryContext)
                                                                      throws net.sf.saxon.trans.XPathException,
                                                                             IOException
A factory method to create the XQuery expression

Throws:
net.sf.saxon.trans.XPathException
IOException

createDynamicContext

protected net.sf.saxon.query.DynamicQueryContext createDynamicContext(Exchange exchange)
                                                               throws Exception
Creates a dynamic context for the given exchange

Throws:
Exception

configureQuery

protected void configureQuery(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext,
                              Exchange exchange)
                       throws Exception
Configures the dynamic context with exchange specific parameters

Throws:
Exception

addParameters

protected void addParameters(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext,
                             Map<String,Object> map)

addParameters

protected void addParameters(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext,
                             Map<String,Object> map,
                             String parameterPrefix)

matches

protected boolean matches(Exchange exchange,
                          List results)

initialize

protected void initialize(Exchange exchange)
                   throws net.sf.saxon.trans.XPathException,
                          IOException
Initializes this builder - Must be invoked before evaluation.

Throws:
net.sf.saxon.trans.XPathException
IOException


Copyright © 2007-2010 IONA Open Source Community. All Rights Reserved.