Class XQueryBuilder
- java.lang.Object
-
- 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.
-
-
Constructor Summary
Constructors Constructor Description XQueryBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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 parametersprotected net.sf.saxon.query.DynamicQueryContext
createDynamicContext(org.apache.camel.Exchange exchange)
Creates a dynamic context for the given exchangeprotected abstract net.sf.saxon.query.XQueryExpression
createQueryExpression(net.sf.saxon.query.StaticQueryContext staticQueryContext)
A factory method to create the XQuery expressionObject
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)
protected net.sf.saxon.om.Item
getAsParameter(Object value)
net.sf.saxon.Configuration
getConfiguration()
Map<String,Object>
getConfigurationProperties()
net.sf.saxon.query.XQueryExpression
getExpression()
String
getHeaderName()
net.sf.saxon.lib.ModuleURIResolver
getModuleURIResolver()
Map<String,String>
getNamespaces()
Map<String,Object>
getParameters()
Properties
getProperties()
ResultFormat
getResultsFormat()
Class<?>
getResultType()
protected Source
getSource(org.apache.camel.Exchange exchange, Object body)
net.sf.saxon.query.StaticQueryContext
getStaticQueryContext()
void
init(org.apache.camel.CamelContext context)
boolean
isAllowStAX()
protected boolean
isInputStreamNeeded(org.apache.camel.Exchange exchange)
Checks whether we need anInputStream
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
setConfigurationProperties(Map<String,Object> configurationProperties)
void
setHeaderName(String headerName)
void
setModuleURIResolver(net.sf.saxon.lib.ModuleURIResolver moduleURIResolver)
void
setNamespaces(Map<String,String> namespaces)
Configures the namespace context from the given DOM elementvoid
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(InputStream in)
Creates a newXQueryBuilder
to evaluate against the expression loaded from the input stream.static XQueryBuilder
xquery(InputStream in, String characterSet)
Creates a newXQueryBuilder
to evaluate against the expression loaded from the input stream.static XQueryBuilder
xquery(Reader reader)
Creates a newXQueryBuilder
to evaluate against the expression loaded from the reader.static XQueryBuilder
xquery(String queryText)
Creates a newXQueryBuilder
to evaluate against the expression from the string.
-
-
-
Method Detail
-
process
public void process(org.apache.camel.Exchange exchange) throws Exception
- Specified by:
process
in interfaceorg.apache.camel.Processor
- Throws:
Exception
-
init
public void init(org.apache.camel.CamelContext context)
- Specified by:
init
in interfaceorg.apache.camel.Expression
- Specified by:
init
in interfaceorg.apache.camel.Predicate
-
evaluate
public <T> T evaluate(org.apache.camel.Exchange exchange, Class<T> type)
- Specified by:
evaluate
in interfaceorg.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 interfaceorg.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)
Creates a newXQueryBuilder
to evaluate against the expression from the string. Important: The builder must be initialized before use.
-
xquery
public static XQueryBuilder xquery(Reader reader)
Creates a newXQueryBuilder
to evaluate against the expression loaded from the reader. Important: The builder must be initialized before use.
-
xquery
public static XQueryBuilder xquery(InputStream in, String characterSet)
Creates a newXQueryBuilder
to evaluate against the expression loaded from the input stream. Important: The builder must be initialized before use.
-
xquery
public static XQueryBuilder xquery(InputStream in)
Creates a newXQueryBuilder
to evaluate against the expression loaded from the input stream. Important: The builder must be initialized before use.
-
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 asSource
.
-
setNamespaces
public void setNamespaces(Map<String,String> namespaces)
Configures the namespace context from the given DOM element- Specified by:
setNamespaces
in interfaceorg.apache.camel.spi.NamespaceAware
-
getNamespaces
public Map<String,String> getNamespaces()
- Specified by:
getNamespaces
in interfaceorg.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)
-
setConfigurationProperties
public void setConfigurationProperties(Map<String,Object> configurationProperties)
-
getStaticQueryContext
public net.sf.saxon.query.StaticQueryContext getStaticQueryContext()
-
setStaticQueryContext
public void setStaticQueryContext(net.sf.saxon.query.StaticQueryContext staticQueryContext)
-
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)
-
getHeaderName
public String getHeaderName()
-
setHeaderName
public void setHeaderName(String headerName)
-
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 anInputStream
to access the message body. Depending on the content in the message body, we may not need to convert toInputStream
.- Parameters:
exchange
- the current exchange- Returns:
- true to convert to
InputStream
beforehand converting toSource
afterwards.
-
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)
-
getAsParameter
protected net.sf.saxon.om.Item getAsParameter(Object value)
-
matches
protected boolean matches(org.apache.camel.Exchange exchange, List<?> results)
-
-