lux
Class Compiler

java.lang.Object
  extended by lux.Compiler

public class Compiler
extends Object

Compiles XQuery using Saxon's compiler and optimizes it for use with a Lucene index. This class is thread-safe, and should be re-used for multiple queries.


Nested Class Summary
static class Compiler.SearchStrategy
           
 
Constructor Summary
Compiler(IndexConfiguration config)
          Creates a Compiler configured according to the given IndexConfiguration.
Compiler(net.sf.saxon.s9api.Processor processor, IndexConfiguration indexConfig)
          Creates a Compiler using the provided Processor and IndexConfiguration.
 
Method Summary
 net.sf.saxon.s9api.XQueryExecutable compile(String exprString)
          Compiles the XQuery expression (main module) using a Saxon XQueryCompiler, then translates it into a mutable AbstractExpression tree using a SaxonTranslator, optimizes it with a PathOptimizer, and then re-serializes and re-compiles.
 net.sf.saxon.s9api.XQueryExecutable compile(String exprString, ErrorListener errorListener)
           
 net.sf.saxon.s9api.XQueryExecutable compile(String exprString, ErrorListener errorListener, URI baseURI)
          Compiles an XQuery expression, returning a Saxon XQueryExecutable.
 net.sf.saxon.lib.CollectionURIResolver getDefaultCollectionURIResolver()
           
 IndexConfiguration getIndexConfiguration()
           
 XQuery getLastOptimized()
           
 net.sf.saxon.s9api.Processor getProcessor()
           
 Compiler.SearchStrategy getSearchStrategy()
           
 String getUriFieldName()
           
 net.sf.saxon.s9api.XPathCompiler getXPathCompiler()
           
 net.sf.saxon.s9api.XQueryCompiler getXQueryCompiler()
           
 net.sf.saxon.s9api.XsltCompiler getXsltCompiler()
           
 boolean isSaxonLicensed()
           
 SaxonTranslator makeTranslator()
           
 void setSearchStrategy(Compiler.SearchStrategy searchStrategy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compiler

public Compiler(IndexConfiguration config)
Creates a Compiler configured according to the given IndexConfiguration. A Saxon Processor is generated using the installed version of Saxon. If a licensed version of Saxon (PE or EE) is installed, the presence of a license is asserted so as to enable the use of licensed Saxon features.

Parameters:
config - the index configuration

Compiler

public Compiler(net.sf.saxon.s9api.Processor processor,
                IndexConfiguration indexConfig)
Creates a Compiler using the provided Processor and IndexConfiguration.

Parameters:
processor - the Saxon Processor
indexConfig - the index configuration
Method Detail

compile

public net.sf.saxon.s9api.XQueryExecutable compile(String exprString)
                                            throws LuxException
Compiles the XQuery expression (main module) using a Saxon XQueryCompiler, then translates it into a mutable AbstractExpression tree using a SaxonTranslator, optimizes it with a PathOptimizer, and then re-serializes and re-compiles.

Parameters:
exprString - the XQuery source
Returns:
the compiled XQuery expression
Throws:
LuxException - if any error occurs while compiling, such as a static XQuery error or syntax error.

compile

public net.sf.saxon.s9api.XQueryExecutable compile(String exprString,
                                                   ErrorListener errorListener)
                                            throws LuxException
Throws:
LuxException

compile

public net.sf.saxon.s9api.XQueryExecutable compile(String exprString,
                                                   ErrorListener errorListener,
                                                   URI baseURI)
                                            throws LuxException
Compiles an XQuery expression, returning a Saxon XQueryExecutable.

Parameters:
exprString - the expression to compile
errorListener - receives any errors generated while compiling; may be null, in which case any errors generated will be lost
baseURI - the base URI of the compiled query
Returns:
the compiled, executable query object
Throws:
LuxException - when a compilation error occurs. The message is typically unhelpful; meaningful errors are stored in the errorListener

getXsltCompiler

public net.sf.saxon.s9api.XsltCompiler getXsltCompiler()

getXQueryCompiler

public net.sf.saxon.s9api.XQueryCompiler getXQueryCompiler()

getXPathCompiler

public net.sf.saxon.s9api.XPathCompiler getXPathCompiler()

getIndexConfiguration

public IndexConfiguration getIndexConfiguration()

getProcessor

public net.sf.saxon.s9api.Processor getProcessor()

makeTranslator

public SaxonTranslator makeTranslator()

getDefaultCollectionURIResolver

public net.sf.saxon.lib.CollectionURIResolver getDefaultCollectionURIResolver()

getUriFieldName

public String getUriFieldName()

getSearchStrategy

public Compiler.SearchStrategy getSearchStrategy()
Returns:
the strategy that defines the way in which optimizer-generated searches are to be encoded: either as calls to lux:search(), or as calls to collection() with a uri beginning "lux:".

setSearchStrategy

public void setSearchStrategy(Compiler.SearchStrategy searchStrategy)

isSaxonLicensed

public boolean isSaxonLicensed()

getLastOptimized

public XQuery getLastOptimized()
Returns:
the last query that was compiled, in its translated and optimized form.


Copyright © 2013. All Rights Reserved.