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 Details

    • XQueryBuilder

      public XQueryBuilder()
  • Method Details

    • 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
    • init

      public void init(org.apache.camel.CamelContext context)
      Specified by:
      init in interface org.apache.camel.Expression
      Specified by:
      init in interface org.apache.camel.Predicate
    • 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)
      Creates a new XQueryBuilder 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 new XQueryBuilder 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 new XQueryBuilder 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 new XQueryBuilder 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 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
    • getNamespaces

      public Map<String,String> getNamespaces()
      Specified by:
      getNamespaces in interface org.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)
    • getConfigurationProperties

      public Map<String,Object> getConfigurationProperties()
    • 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)
    • 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)
    • getSource

      public org.apache.camel.Expression getSource()
    • setSource

      public void setSource(org.apache.camel.Expression source)
    • 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(Object payload)
      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.

      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:

      • StAX - Is StAX is allowed
      • SAX - SAX as 2nd choice
      • Stream - Stream as 3rd choice
      • DOM - DOM as 4th choice
    • 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)