org.apache.camel.component.xquery
Class XQueryBuilder

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

public abstract class XQueryBuilder
extends Object
implements org.apache.camel.Expression, org.apache.camel.Predicate, org.apache.camel.spi.NamespaceAware, org.apache.camel.Processor

Creates an XQuery builder.

The XQueryExpression, as you would expect, can be executed repeatedly, as often as you want, in the same or in different threads.

Version:

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 allowStAX()
          Enables to allow using StAX.
 XQueryBuilder asBytes()
           
 XQueryBuilder asBytesSource()
           
 XQueryBuilder asDOM()
           
 XQueryBuilder asDOMSource()
           
 XQueryBuilder asList()
           
 void assertMatches(String text, org.apache.camel.Exchange exchange)
          Deprecated. 
 XQueryBuilder asString()
           
 XQueryBuilder asStringSource()
           
protected  void configureQuery(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext, org.apache.camel.Exchange exchange)
          Configures the dynamic context with exchange specific parameters
protected  net.sf.saxon.query.DynamicQueryContext createDynamicContext(org.apache.camel.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(org.apache.camel.Exchange exchange)
           
<T> T
evaluate(org.apache.camel.Exchange exchange, Class<T> type)
           
 byte[] evaluateAsBytes(org.apache.camel.Exchange exchange)
           
 Object evaluateAsBytesSource(org.apache.camel.Exchange exchange)
           
 Node evaluateAsDOM(org.apache.camel.Exchange exchange)
           
 List<?> evaluateAsList(org.apache.camel.Exchange exchange)
           
 String evaluateAsString(org.apache.camel.Exchange exchange)
           
 Object evaluateAsStringSource(org.apache.camel.Exchange exchange)
           
 net.sf.saxon.Configuration getConfiguration()
           
 net.sf.saxon.query.XQueryExpression getExpression()
           
 net.sf.saxon.lib.ModuleURIResolver getModuleURIResolver()
           
 Map<String,Object> getParameters()
           
 Properties getProperties()
           
 ResultFormat getResultsFormat()
           
 Class<?> getResultType()
           
protected  Source getSource(org.apache.camel.Exchange exchange, Object body)
          Converts the inbound body to a Source, if the body is not already a Source.
 net.sf.saxon.query.StaticQueryContext getStaticQueryContext()
           
protected  void initialize(org.apache.camel.Exchange exchange)
          Initializes this builder - Must be invoked before evaluation.
 boolean isAllowStAX()
           
protected  boolean isInputStreamNeeded(org.apache.camel.Exchange exchange)
          Checks whether we need an InputStream to access the message body.
 boolean isStripsAllWhiteSpace()
           
 boolean matches(org.apache.camel.Exchange exchange)
           
protected  boolean matches(org.apache.camel.Exchange exchange, List<?> results)
           
 XQueryBuilder namespace(String prefix, String uri)
           
 XQueryBuilder parameter(String name, Object value)
           
 void process(org.apache.camel.Exchange exchange)
           
 XQueryBuilder resultType(Class<?> resultType)
           
 void setAllowStAX(boolean allowStAX)
           
 void setConfiguration(net.sf.saxon.Configuration configuration)
           
 void setModuleURIResolver(net.sf.saxon.lib.ModuleURIResolver moduleURIResolver)
           
 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)
           
 void setStripsAllWhiteSpace(boolean stripsAllWhiteSpace)
           
 XQueryBuilder stripsAllWhiteSpace()
           
 XQueryBuilder stripsIgnorableWhiteSpace()
           
 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(org.apache.camel.Exchange exchange)
             throws Exception
Specified by:
process in interface org.apache.camel.Processor
Throws:
Exception

evaluate

public <T> T evaluate(org.apache.camel.Exchange exchange,
                      Class<T> type)
Specified by:
evaluate in interface org.apache.camel.Expression

evaluate

public Object evaluate(org.apache.camel.Exchange exchange)

evaluateAsList

public List<?> evaluateAsList(org.apache.camel.Exchange exchange)
                       throws Exception
Throws:
Exception

evaluateAsStringSource

public Object evaluateAsStringSource(org.apache.camel.Exchange exchange)
                              throws Exception
Throws:
Exception

evaluateAsBytesSource

public Object evaluateAsBytesSource(org.apache.camel.Exchange exchange)
                             throws Exception
Throws:
Exception

evaluateAsDOM

public Node evaluateAsDOM(org.apache.camel.Exchange exchange)
                   throws Exception
Throws:
Exception

evaluateAsBytes

public byte[] evaluateAsBytes(org.apache.camel.Exchange exchange)
                       throws Exception
Throws:
Exception

evaluateAsString

public String evaluateAsString(org.apache.camel.Exchange exchange)
                        throws Exception
Throws:
Exception

matches

public boolean matches(org.apache.camel.Exchange exchange)
Specified by:
matches in interface org.apache.camel.Predicate

assertMatches

@Deprecated
public void assertMatches(String text,
                                     org.apache.camel.Exchange exchange)
                   throws AssertionError
Deprecated. 

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()

stripsAllWhiteSpace

public XQueryBuilder stripsAllWhiteSpace()

stripsIgnorableWhiteSpace

public XQueryBuilder stripsIgnorableWhiteSpace()

allowStAX

public XQueryBuilder allowStAX()
Enables to allow using StAX.

When enabled StAX is preferred as the first choice as Source.


setNamespaces

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

Specified by:
setNamespaces in interface org.apache.camel.spi.NamespaceAware

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)

getModuleURIResolver

public net.sf.saxon.lib.ModuleURIResolver getModuleURIResolver()

setModuleURIResolver

public void setModuleURIResolver(net.sf.saxon.lib.ModuleURIResolver moduleURIResolver)

isStripsAllWhiteSpace

public boolean isStripsAllWhiteSpace()

setStripsAllWhiteSpace

public void setStripsAllWhiteSpace(boolean stripsAllWhiteSpace)

isAllowStAX

public boolean isAllowStAX()

setAllowStAX

public void setAllowStAX(boolean allowStAX)

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(org.apache.camel.Exchange exchange)
                                                               throws Exception
Creates a dynamic context for the given exchange

Throws:
Exception

isInputStreamNeeded

protected boolean isInputStreamNeeded(org.apache.camel.Exchange exchange)
Checks whether we need an InputStream to access the message body.

Depending on the content in the message body, we may not need to convert to InputStream.

Parameters:
exchange - the current exchange
Returns:
true to convert to InputStream beforehand converting to Source afterwards.

getSource

protected Source getSource(org.apache.camel.Exchange exchange,
                           Object body)
Converts the inbound body to a Source, if the body is not already a Source.

This implementation will prefer to source in the following order:


configureQuery

protected void configureQuery(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext,
                              org.apache.camel.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(org.apache.camel.Exchange exchange,
                          List<?> results)

initialize

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

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


Apache CAMEL