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 voidaddParameters(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext, Map<String,Object> map)protected voidaddParameters(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext, Map<String,Object> map, String parameterPrefix)XQueryBuilderallowStAX()Enables to allow using StAX.XQueryBuilderasBytes()XQueryBuilderasBytesSource()XQueryBuilderasDOM()XQueryBuilderasDOMSource()XQueryBuilderasList()voidassertMatches(String text, org.apache.camel.Exchange exchange)Deprecated.XQueryBuilderasString()XQueryBuilderasStringSource()protected voidconfigureQuery(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext, org.apache.camel.Exchange exchange)Configures the dynamic context with exchange specific parametersprotected net.sf.saxon.query.DynamicQueryContextcreateDynamicContext(org.apache.camel.Exchange exchange)Creates a dynamic context for the given exchangeprotected abstract net.sf.saxon.query.XQueryExpressioncreateQueryExpression(net.sf.saxon.query.StaticQueryContext staticQueryContext)A factory method to create the XQuery expressionObjectevaluate(org.apache.camel.Exchange exchange)<T> Tevaluate(org.apache.camel.Exchange exchange, Class<T> type)byte[]evaluateAsBytes(org.apache.camel.Exchange exchange)ObjectevaluateAsBytesSource(org.apache.camel.Exchange exchange)NodeevaluateAsDOM(org.apache.camel.Exchange exchange)List<?>evaluateAsList(org.apache.camel.Exchange exchange)StringevaluateAsString(org.apache.camel.Exchange exchange)ObjectevaluateAsStringSource(org.apache.camel.Exchange exchange)protected net.sf.saxon.om.ItemgetAsParameter(Object value)net.sf.saxon.ConfigurationgetConfiguration()Map<String,Object>getConfigurationProperties()net.sf.saxon.query.XQueryExpressiongetExpression()StringgetHeaderName()net.sf.saxon.lib.ModuleURIResolvergetModuleURIResolver()Map<String,String>getNamespaces()Map<String,Object>getParameters()PropertiesgetProperties()StringgetPropertyName()ResultFormatgetResultsFormat()Class<?>getResultType()protected SourcegetSource(org.apache.camel.Exchange exchange, Object body)net.sf.saxon.query.StaticQueryContextgetStaticQueryContext()voidinit(org.apache.camel.CamelContext context)booleanisAllowStAX()protected booleanisInputStreamNeeded(org.apache.camel.Exchange exchange)Checks whether we need anInputStreamto access the message body.booleanisStripsAllWhiteSpace()protected booleanmatches(List<?> results)booleanmatches(org.apache.camel.Exchange exchange)XQueryBuildernamespace(String prefix, String uri)XQueryBuilderparameter(String name, Object value)voidprocess(org.apache.camel.Exchange exchange)XQueryBuilderresultType(Class<?> resultType)voidsetAllowStAX(boolean allowStAX)voidsetConfiguration(net.sf.saxon.Configuration configuration)voidsetConfigurationProperties(Map<String,Object> configurationProperties)voidsetHeaderName(String headerName)Name of header to use as input, instead of the message bodyvoidsetModuleURIResolver(net.sf.saxon.lib.ModuleURIResolver moduleURIResolver)voidsetNamespaces(Map<String,String> namespaces)Configures the namespace context from the given DOM elementvoidsetParameters(Map<String,Object> parameters)voidsetProperties(Properties properties)voidsetPropertyName(String propertyName)Name of property to use as input, instead of the message body.voidsetResultsFormat(ResultFormat resultsFormat)voidsetResultType(Class<?> resultType)voidsetStaticQueryContext(net.sf.saxon.query.StaticQueryContext staticQueryContext)voidsetStripsAllWhiteSpace(boolean stripsAllWhiteSpace)XQueryBuilderstripsAllWhiteSpace()XQueryBuilderstripsIgnorableWhiteSpace()StringtoString()static XQueryBuilderxquery(InputStream in)Creates a newXQueryBuilderto evaluate against the expression loaded from the input stream.static XQueryBuilderxquery(InputStream in, String characterSet)Creates a newXQueryBuilderto evaluate against the expression loaded from the input stream.static XQueryBuilderxquery(Reader reader)Creates a newXQueryBuilderto evaluate against the expression loaded from the reader.static XQueryBuilderxquery(String queryText)Creates a newXQueryBuilderto evaluate against the expression from the string.
-
-
-
Method Detail
-
process
public void process(org.apache.camel.Exchange exchange) throws Exception- Specified by:
processin interfaceorg.apache.camel.Processor- Throws:
Exception
-
init
public void init(org.apache.camel.CamelContext context)
- Specified by:
initin interfaceorg.apache.camel.Expression- Specified by:
initin interfaceorg.apache.camel.Predicate
-
evaluate
public <T> T evaluate(org.apache.camel.Exchange exchange, Class<T> type)- Specified by:
evaluatein 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:
matchesin 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 newXQueryBuilderto evaluate against the expression from the string. Important: The builder must be initialized before use.
-
xquery
public static XQueryBuilder xquery(Reader reader)
Creates a newXQueryBuilderto 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 newXQueryBuilderto 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 newXQueryBuilderto 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:
setNamespacesin interfaceorg.apache.camel.spi.NamespaceAware
-
getNamespaces
public Map<String,String> getNamespaces()
- Specified by:
getNamespacesin interfaceorg.apache.camel.spi.NamespaceAware
-
getExpression
public net.sf.saxon.query.XQueryExpression getExpression()
-
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)
Name of header to use as input, instead of the message body
-
getPropertyName
public String getPropertyName()
-
setPropertyName
public void setPropertyName(String propertyName)
Name of property to use as input, instead of the message body.It has a lower precedent than the name of header if both are set.
-
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, IOExceptionA factory method to create the XQuery expression- Throws:
net.sf.saxon.trans.XPathExceptionIOException
-
createDynamicContext
protected net.sf.saxon.query.DynamicQueryContext createDynamicContext(org.apache.camel.Exchange exchange) throws ExceptionCreates a dynamic context for the given exchange- Throws:
Exception
-
isInputStreamNeeded
protected boolean isInputStreamNeeded(org.apache.camel.Exchange exchange)
Checks whether we need anInputStreamto 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
InputStreambeforehand converting toSourceafterwards.
-
configureQuery
protected void configureQuery(net.sf.saxon.query.DynamicQueryContext dynamicQueryContext, org.apache.camel.Exchange exchange)Configures the dynamic context with exchange specific parameters
-
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(List<?> results)
-
-