Class QueryTemplateManager
- java.lang.Object
-
- org.apache.lucene.queryparser.xml.QueryTemplateManager
-
public class QueryTemplateManager extends 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 Description QueryTemplateManager()
QueryTemplateManager(InputStream xslIs)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDefaultQueryTemplate(InputStream xslIs)
void
addQueryTemplate(String name, InputStream xslIs)
Document
getQueryAsDOM(Properties formProperties)
static Document
getQueryAsDOM(Properties formProperties, InputStream xslIs)
Slow means of constructing query - parses stylesheet from input streamDocument
getQueryAsDOM(Properties formProperties, String queryTemplateName)
static Document
getQueryAsDOM(Properties formProperties, Templates template)
Fast means of constructing query using a cached,precompiled stylesheetString
getQueryAsXmlString(Properties formProperties)
static String
getQueryAsXmlString(Properties formProperties, InputStream xslIs)
Slow means of constructing query parsing a stylesheet from an input streamString
getQueryAsXmlString(Properties formProperties, String queryTemplateName)
static String
getQueryAsXmlString(Properties formProperties, Templates template)
Fast means of constructing query using a precompiled stylesheetstatic Templates
getTemplates(InputStream xslIs)
Parses a query stylesheet for repeated usestatic void
transformCriteria(Properties formProperties, InputStream xslIs, Result result)
Slower transformation using an uncompiled stylesheet (suitable for development environment)static void
transformCriteria(Properties formProperties, Templates template, Result result)
Fast transformation using a pre-compiled stylesheet (suitable for production environments)static void
transformCriteria(Properties formProperties, Transformer transformer, Result result)
-
-
-
Constructor Detail
-
QueryTemplateManager
public QueryTemplateManager()
-
QueryTemplateManager
public QueryTemplateManager(InputStream xslIs) throws TransformerConfigurationException, ParserConfigurationException, SAXException, IOException
-
-
Method Detail
-
addDefaultQueryTemplate
public void addDefaultQueryTemplate(InputStream xslIs) throws TransformerConfigurationException, ParserConfigurationException, SAXException, IOException
-
addQueryTemplate
public void addQueryTemplate(String name, InputStream xslIs) throws TransformerConfigurationException, ParserConfigurationException, SAXException, IOException
-
getQueryAsXmlString
public String getQueryAsXmlString(Properties formProperties, String queryTemplateName) throws SAXException, IOException, ParserConfigurationException, TransformerException
-
getQueryAsDOM
public Document getQueryAsDOM(Properties formProperties, String queryTemplateName) throws SAXException, IOException, ParserConfigurationException, TransformerException
-
getQueryAsXmlString
public String getQueryAsXmlString(Properties formProperties) throws SAXException, IOException, ParserConfigurationException, TransformerException
-
getQueryAsDOM
public Document getQueryAsDOM(Properties formProperties) throws SAXException, IOException, ParserConfigurationException, TransformerException
-
getQueryAsXmlString
public static String getQueryAsXmlString(Properties formProperties, Templates template) throws ParserConfigurationException, TransformerException
Fast means of constructing query using a precompiled stylesheet
-
getQueryAsXmlString
public static String getQueryAsXmlString(Properties formProperties, InputStream xslIs) throws SAXException, IOException, ParserConfigurationException, TransformerException
Slow means of constructing query parsing a stylesheet from an input stream
-
getQueryAsDOM
public static Document getQueryAsDOM(Properties formProperties, Templates template) throws ParserConfigurationException, TransformerException
Fast means of constructing query using a cached,precompiled stylesheet
-
getQueryAsDOM
public static Document getQueryAsDOM(Properties formProperties, InputStream xslIs) throws SAXException, IOException, ParserConfigurationException, TransformerException
Slow means of constructing query - parses stylesheet from input stream
-
transformCriteria
public static void transformCriteria(Properties formProperties, InputStream xslIs, Result result) throws SAXException, IOException, ParserConfigurationException, TransformerException
Slower transformation using an uncompiled stylesheet (suitable for development environment)
-
transformCriteria
public static void transformCriteria(Properties formProperties, Templates template, Result result) throws ParserConfigurationException, TransformerException
Fast transformation using a pre-compiled stylesheet (suitable for production environments)
-
transformCriteria
public static void transformCriteria(Properties formProperties, Transformer transformer, Result result) throws ParserConfigurationException, TransformerException
-
getTemplates
public static Templates getTemplates(InputStream xslIs) throws ParserConfigurationException, SAXException, IOException, TransformerConfigurationException
Parses a query stylesheet for repeated use
-
-