SMILA (incubation) API documentation

org.eclipse.smila.search.templates
Class TemplateRegistryController

java.lang.Object
  extended by org.eclipse.smila.search.templates.TemplateRegistryController

public abstract class TemplateRegistryController
extends java.lang.Object

A cache and manager for Search- and FieldTemplates. If a template is not defined then an empty dummy template is created.

Author:
August Georg Schmidt (BROX)

Method Summary
static ITerm applyFieldTemplate(DField dField, DFieldTemplate dTemplate, IndexConnection ic)
          Apply field template.
static IQueryExpression applyTemplate(DQuery dQuery, DTemplate dTemplate, IndexConnection ic)
           
static boolean doesFieldMatchTemplate(DQuery query, DField field, DFieldTemplate template)
          Checks whether a field does match a template.
static DFieldTemplate getFieldTemplate(DQuery query, DField field, java.lang.String indexName)
          Get field template for simple search field.
static DFieldTemplates getFieldTemplates(java.lang.String indexName)
          Returns the template for the given index.
static DSearchTemplates getSearchTemplates(java.lang.String indexName)
          Resolves all search templates for a given index.
static DTemplate getTemplate(DQuery dQuery)
          Get template for simple search.
static boolean matchesFilterExpression(java.lang.String filterExpression, DQuery query)
          Checks whether a query matches the filter expression.
static void removeTemplates(java.lang.String indexName, boolean doSearchTemplates, boolean doFieldTemplates)
          Removes for the given index the given template(s) from cache and disk.
static void setFieldTemplates(DFieldTemplates templates)
          Takes the given FieldTemplate (a) caches it in .fieldTemplates and saves it to the harddrive.
static void setSearchTemplates(DSearchTemplates templates)
          Takes the given SearchTemplate (a) caches it in .searchTemplates and saves it to the harddrive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTemplate

public static DTemplate getTemplate(DQuery dQuery)
                             throws TemplateException
Get template for simple search.

Parameters:
dQuery - Simple search query.
Returns:
Search template or null.
Throws:
TemplateException - Unable to get template.

getFieldTemplate

public static DFieldTemplate getFieldTemplate(DQuery query,
                                              DField field,
                                              java.lang.String indexName)
                                       throws TemplateException
Get field template for simple search field.

Parameters:
query - Simple search query.
field - Field from simple search.
indexName - index name.
Returns:
Field template or null.
Throws:
TemplateException - Unable to get template.

doesFieldMatchTemplate

public static boolean doesFieldMatchTemplate(DQuery query,
                                             DField field,
                                             DFieldTemplate template)
Checks whether a field does match a template.

Parameters:
query - Query.
field - Field.
template - Template.
Returns:
Whether a field matches a template.

matchesFilterExpression

public static boolean matchesFilterExpression(java.lang.String filterExpression,
                                              DQuery query)
                                       throws TemplateException
Checks whether a query matches the filter expression.

Parameters:
filterExpression - Filter expression.
query - Query.
Returns:
Whether query matches.
Throws:
TemplateException - -

applyTemplate

public static IQueryExpression applyTemplate(DQuery dQuery,
                                             DTemplate dTemplate,
                                             IndexConnection ic)
                                      throws TemplateException,
                                             NodeTransformerException,
                                             IndexException
Parameters:
dQuery - Search query.
dTemplate - Search template.
ic - Index connection.
Returns:
Query expression.
Throws:
TemplateException - Unable to apply search template.
NodeTransformerException - Unable to apply node transformers.
IndexException - Unable to apply search template.

applyFieldTemplate

public static ITerm applyFieldTemplate(DField dField,
                                       DFieldTemplate dTemplate,
                                       IndexConnection ic)
                                throws TemplateException,
                                       NodeTransformerException,
                                       IndexException
Apply field template.

Parameters:
dField - Query field.
dTemplate - Template.
ic - Index connection.
Returns:
Subterm containing applied field template.
Throws:
TemplateException - Unable to apply field template.
NodeTransformerException - Unable to apply node transformers.
IndexException - Error applying field templates.

setSearchTemplates

public static void setSearchTemplates(DSearchTemplates templates)
                               throws TemplateException
Takes the given SearchTemplate (a) caches it in .searchTemplates and saves it to the harddrive.

Parameters:
templates - Search templates for a index.
Throws:
TemplateException - Unable to set search templates.

getSearchTemplates

public static DSearchTemplates getSearchTemplates(java.lang.String indexName)
                                           throws TemplateException
Resolves all search templates for a given index.

Parameters:
indexName - Index name.
Returns:
Search templates.
Throws:
TemplateException - Unable to get search templates.

setFieldTemplates

public static void setFieldTemplates(DFieldTemplates templates)
                              throws TemplateException
Takes the given FieldTemplate (a) caches it in .fieldTemplates and saves it to the harddrive.

Parameters:
templates - Field templates for a index.
Throws:
TemplateException - Unable to set field templates.

getFieldTemplates

public static DFieldTemplates getFieldTemplates(java.lang.String indexName)
                                         throws TemplateException
Returns the template for the given index. These attempts are made in this order: 1. cache; 2. file 3. dummy

Parameters:
indexName - Index name.
Returns:
Field templates.
Throws:
TemplateException - Unable to resolve field templates.

removeTemplates

public static void removeTemplates(java.lang.String indexName,
                                   boolean doSearchTemplates,
                                   boolean doFieldTemplates)
Removes for the given index the given template(s) from cache and disk. The method is optimistic, ie it doesnt check for existance of the given index nor the successful removal from cache and disk and consequently doesnt throw any exception.

Parameters:
indexName - Index name.
doSearchTemplates - Whether search templates should be deleted.
doFieldTemplates - Whether field templates should be deleted.

SMILA (incubation) API documentation