org.apache.lucene.xmlparser

## Class QueryTemplateManager

- java.lang.Object
- - org.apache.lucene.xmlparser.QueryTemplateManager

-     public class QueryTemplateManager
      extends java.lang.Object

  Provides utilities for turning query form input (such as from a web page or Swing gui) into Lucene XML queries by using XSL templates. This approach offers a convenient way of externalizing and changing how user input is turned into Lucene queries. Database applications often adopt similar practices by externalizing SQL in template files that can be easily changed/optimized by a DBA. The static methods can be used on their own or by creating an instance of this class you can store and re-use compiled stylesheets for fast use (e.g. in a server environment)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryTemplateManager()`
    `QueryTemplateManager(java.io.InputStream xslIs)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDefaultQueryTemplate(java.io.InputStream xslIs)`
    `void` | `addQueryTemplate(java.lang.String name, java.io.InputStream xslIs)`
    `org.w3c.dom.Document` | `getQueryAsDOM(java.util.Properties formProperties)`
    `static org.w3c.dom.Document` | `getQueryAsDOM(java.util.Properties formProperties, java.io.InputStream xslIs)` Slow means of constructing query - parses stylesheet from input stream
    `org.w3c.dom.Document` | `getQueryAsDOM(java.util.Properties formProperties, java.lang.String queryTemplateName)`
    `static org.w3c.dom.Document` | `getQueryAsDOM(java.util.Properties formProperties, javax.xml.transform.Templates template)` Fast means of constructing query using a cached,precompiled stylesheet
    `java.lang.String` | `getQueryAsXmlString(java.util.Properties formProperties)`
    `static java.lang.String` | `getQueryAsXmlString(java.util.Properties formProperties, java.io.InputStream xslIs)` Slow means of constructing query parsing a stylesheet from an input stream
    `java.lang.String` | `getQueryAsXmlString(java.util.Properties formProperties, java.lang.String queryTemplateName)`
    `static java.lang.String` | `getQueryAsXmlString(java.util.Properties formProperties, javax.xml.transform.Templates template)` Fast means of constructing query using a precompiled stylesheet
    `static javax.xml.transform.Templates` | `getTemplates(java.io.InputStream xslIs)` Parses a query stylesheet for repeated use
    `static void` | `transformCriteria(java.util.Properties formProperties, java.io.InputStream xslIs, javax.xml.transform.Result result)` Slower transformation using an uncompiled stylesheet (suitable for development environment)
    `static void` | `transformCriteria(java.util.Properties formProperties, javax.xml.transform.Templates template, javax.xml.transform.Result result)` Fast transformation using a pre-compiled stylesheet (suitable for production environments)
    `static void` | `transformCriteria(java.util.Properties formProperties, javax.xml.transform.Transformer transformer, javax.xml.transform.Result result)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### QueryTemplateManager

          public QueryTemplateManager()

    - #### QueryTemplateManager

          public QueryTemplateManager(java.io.InputStream xslIs)
                               throws javax.xml.transform.TransformerConfigurationException,
                                      javax.xml.parsers.ParserConfigurationException,
                                      org.xml.sax.SAXException,
                                      java.io.IOException

      Throws:
        `javax.xml.transform.TransformerConfigurationException`
        `javax.xml.parsers.ParserConfigurationException`
        `org.xml.sax.SAXException`
        `java.io.IOException`

  - ### Method Detail

    - #### addDefaultQueryTemplate

          public void addDefaultQueryTemplate(java.io.InputStream xslIs)
                                       throws javax.xml.transform.TransformerConfigurationException,
                                              javax.xml.parsers.ParserConfigurationException,
                                              org.xml.sax.SAXException,
                                              java.io.IOException

      Throws:
        `javax.xml.transform.TransformerConfigurationException`
        `javax.xml.parsers.ParserConfigurationException`
        `org.xml.sax.SAXException`
        `java.io.IOException`

    - #### addQueryTemplate

          public void addQueryTemplate(java.lang.String name,
                                       java.io.InputStream xslIs)
                                throws javax.xml.transform.TransformerConfigurationException,
                                       javax.xml.parsers.ParserConfigurationException,
                                       org.xml.sax.SAXException,
                                       java.io.IOException

      Throws:
        `javax.xml.transform.TransformerConfigurationException`
        `javax.xml.parsers.ParserConfigurationException`
        `org.xml.sax.SAXException`
        `java.io.IOException`

    - #### getQueryAsXmlString

          public java.lang.String getQueryAsXmlString(java.util.Properties formProperties,
                                                      java.lang.String queryTemplateName)
                                               throws org.xml.sax.SAXException,
                                                      java.io.IOException,
                                                      javax.xml.parsers.ParserConfigurationException,
                                                      javax.xml.transform.TransformerException

      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`

    - #### getQueryAsDOM

          public org.w3c.dom.Document getQueryAsDOM(java.util.Properties formProperties,
                                                    java.lang.String queryTemplateName)
                                             throws org.xml.sax.SAXException,
                                                    java.io.IOException,
                                                    javax.xml.parsers.ParserConfigurationException,
                                                    javax.xml.transform.TransformerException

      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`

    - #### getQueryAsXmlString

          public java.lang.String getQueryAsXmlString(java.util.Properties formProperties)
                                               throws org.xml.sax.SAXException,
                                                      java.io.IOException,
                                                      javax.xml.parsers.ParserConfigurationException,
                                                      javax.xml.transform.TransformerException

      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`

    - #### getQueryAsDOM

          public org.w3c.dom.Document getQueryAsDOM(java.util.Properties formProperties)
                                             throws org.xml.sax.SAXException,
                                                    java.io.IOException,
                                                    javax.xml.parsers.ParserConfigurationException,
                                                    javax.xml.transform.TransformerException

      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`

    - #### getQueryAsXmlString

          public static java.lang.String getQueryAsXmlString(java.util.Properties formProperties,
                                                             javax.xml.transform.Templates template)
                                                      throws org.xml.sax.SAXException,
                                                             java.io.IOException,
                                                             javax.xml.parsers.ParserConfigurationException,
                                                             javax.xml.transform.TransformerException

      Fast means of constructing query using a precompiled stylesheet
      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`

    - #### getQueryAsXmlString

          public static java.lang.String getQueryAsXmlString(java.util.Properties formProperties,
                                                             java.io.InputStream xslIs)
                                                      throws org.xml.sax.SAXException,
                                                             java.io.IOException,
                                                             javax.xml.parsers.ParserConfigurationException,
                                                             javax.xml.transform.TransformerException

      Slow means of constructing query parsing a stylesheet from an input stream
      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`

    - #### getQueryAsDOM

          public static org.w3c.dom.Document getQueryAsDOM(java.util.Properties formProperties,
                                                           javax.xml.transform.Templates template)
                                                    throws org.xml.sax.SAXException,
                                                           java.io.IOException,
                                                           javax.xml.parsers.ParserConfigurationException,
                                                           javax.xml.transform.TransformerException

      Fast means of constructing query using a cached,precompiled stylesheet
      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`

    - #### getQueryAsDOM

          public static org.w3c.dom.Document getQueryAsDOM(java.util.Properties formProperties,
                                                           java.io.InputStream xslIs)
                                                    throws org.xml.sax.SAXException,
                                                           java.io.IOException,
                                                           javax.xml.parsers.ParserConfigurationException,
                                                           javax.xml.transform.TransformerException

      Slow means of constructing query - parses stylesheet from input stream
      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`

    - #### transformCriteria

          public static void transformCriteria(java.util.Properties formProperties,
                                               java.io.InputStream xslIs,
                                               javax.xml.transform.Result result)
                                        throws org.xml.sax.SAXException,
                                               java.io.IOException,
                                               javax.xml.parsers.ParserConfigurationException,
                                               javax.xml.transform.TransformerException

      Slower transformation using an uncompiled stylesheet (suitable for development environment)
      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`

    - #### transformCriteria

          public static void transformCriteria(java.util.Properties formProperties,
                                               javax.xml.transform.Templates template,
                                               javax.xml.transform.Result result)
                                        throws org.xml.sax.SAXException,
                                               java.io.IOException,
                                               javax.xml.parsers.ParserConfigurationException,
                                               javax.xml.transform.TransformerException

      Fast transformation using a pre-compiled stylesheet (suitable for production environments)
      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`

    - #### transformCriteria

          public static void transformCriteria(java.util.Properties formProperties,
                                               javax.xml.transform.Transformer transformer,
                                               javax.xml.transform.Result result)
                                        throws org.xml.sax.SAXException,
                                               java.io.IOException,
                                               javax.xml.parsers.ParserConfigurationException,
                                               javax.xml.transform.TransformerException

      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`

    - #### getTemplates

          public static javax.xml.transform.Templates getTemplates(java.io.InputStream xslIs)
                                                            throws javax.xml.parsers.ParserConfigurationException,
                                                                   org.xml.sax.SAXException,
                                                                   java.io.IOException,
                                                                   javax.xml.transform.TransformerConfigurationException

      Parses a query stylesheet for repeated use
      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `javax.xml.transform.TransformerConfigurationException`

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.