Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## fr.gouv.culture.sdx.search.lucene.query
Class AbstractQuery

    java.lang.Object
      fr.gouv.culture.sdx.utils.AbstractSdxObject
          fr.gouv.culture.sdx.search.lucene.query.AbstractQuery

All Implemented Interfaces:
  org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, Describable, Encodable, Identifiable, Localizable, org.apache.avalon.framework.logger.LogEnabled, Query, Query, SdxObject, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable

Direct Known Subclasses:
  ComplexQuery, DateIntervalQuery, ExactFieldQuery, FieldQuery, LinearQuery, SimpleQuery

public abstract class AbstractQuery
extends AbstractSdxObject
implements Query

Abstract class for basic SDX query functionalities.

To implement a new SDX query type, it is better to extend this class which takes care of:

- Adding base queries, filters, sort specifications
- Logger management
- Query execution
- Search locations

In building a query, one should following the steps to avoid problems:

1. Create the query, using the constructor
2. set the super.getLog() by calling the enableLogging
3. build the query by calling the setUp method
4. prepare the query with the prepare method
5. use execute method to obtain results

use the toSAX method for info; this method will deliver the best information after the prepare() method has been called

See Also:
  `prepare()`, `execute()`, `toSAX(org.xml.sax.ContentHandler)`

Nested Class Summary

Nested classes inherited from class fr.gouv.culture.sdx.utils.SdxObject
`SdxObject.ConfigurationNode`

Field Summary
`protected int` | `baseOperator` The operator linking this query to the base query.
`protected Query` | `baseQuery` The internal Lucene query for the base query.
`protected Results` | `baseResults` Results of a base query.
`protected CachingRewrittenQueryWrapper` | `cachedQuery` The internal Lucene query wrapper for term collection/highlighting
`protected Filter` | `filter` The filter for this query.
`protected org.apache.lucene.search.Query` | `luceneQuery` The internal Lucene query for this query.
`protected java.lang.String` | `queryText` The requested Text, especially for simple or field queries
`protected SearchLocations` | `searchLocations` A Lucene index to search.
`protected SortSpecification` | `sortSpecification` The sort specification for this query.

Fields inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject
`_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitialized`

Fields inherited from interface fr.gouv.culture.sdx.search.lucene.query.Query
`defaultOperator, LUCENE_BOOLEAN_QUERY_MAX_CLAUSES, OPERATOR_AND, OPERATOR_NOT, OPERATOR_OR, SEARCH_ENGINE`

Fields inherited from interface fr.gouv.culture.sdx.search.Query
`CLASS_NAME_SUFFIX`

Fields inherited from interface fr.gouv.culture.sdx.utils.Encodable
`DEFAULT_ENCODING`

Constructor Summary
`AbstractQuery()`

Method Summary
`protected org.xml.sax.helpers.AttributesImpl` | `addAttributesLucene(org.xml.sax.helpers.AttributesImpl atts)` Factorization of *Query.toSax() components
`protected org.xml.sax.helpers.AttributesImpl` | `addAttributesText(org.xml.sax.helpers.AttributesImpl atts)` Factorization of *Query.toSax() components
`void` | `addBaseQuery(Query query, int operator)` Adds a base query to the current query
`void` | `addBaseQuery(Results results, int operator)` Adds a base query for this query.
`void` | `addFilter(Filter filter)` Adds a filter for this query.
`void` | `addSortSpecification(SortSpecification ss)` Adds a sort specification for this query.
`Results` | `execute()` Executes the query and return results.
`float` | `getBoost()` Returns the boost on the query.
`org.apache.lucene.search.Query` | `getCachedQuery()`
`protected java.lang.String` | `getClassNameSuffix()` Sub classes should element this method to return their class name suffix for SAX output
`org.apache.lucene.search.Query` | `getLuceneQuery()` Returns the internal Lucene query for this query.
`static int` | `getOperator(java.lang.String str)` Returns a query operator from a given string representation.
`SearchLocations` | `getSearchLocations()`
`protected boolean` | `initToSax()` Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML
`protected void` | `initVolatileObjectsToSax()` Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML Some objects need to be refresh each time a toSAX is called
`Filter` | `prepare()` Prepares a query before execution.
`void` | `setBoost(float boost)` Change the boost on the query.
`void` | `setBoost(java.lang.String boost)` Change the boost on the query.
`void` | `setLuceneQuery(org.apache.lucene.search.Query lquery)`
`protected void` | `setSearchLocations(SearchLocations sLocs)` Sets the SearchLocations object
`void` | `setUp()` Does nothing here, please see subclasses
`void` | `setUp(SearchLocations sLocs, org.apache.lucene.search.Query lquery)`
`abstract void` | `toSAX(org.xml.sax.ContentHandler hdl)` Formats a query in XML.

Methods inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject
`configure, configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, service, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, verifyConfigurationResources`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface fr.gouv.culture.sdx.utils.SdxObject
`getLog`

Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled
`enableLogging`

Methods inherited from interface org.apache.avalon.framework.context.Contextualizable
`contextualize`

Methods inherited from interface org.apache.avalon.framework.service.Serviceable
`service`

Methods inherited from interface org.apache.avalon.framework.configuration.Configurable
`configure`

Methods inherited from interface fr.gouv.culture.sdx.utils.Identifiable
`getId, setId`

Methods inherited from interface fr.gouv.culture.sdx.utils.Describable
`getDescription, setDescription`

Methods inherited from interface fr.gouv.culture.sdx.utils.Encodable
`getEncoding, setEncoding`

Methods inherited from interface fr.gouv.culture.sdx.utils.Localizable
`getLocale, getXmlLang, setLocale, setXmlLang`

Field Detail

### searchLocations

    protected SearchLocations searchLocations

  A Lucene index to search.

### queryText

    protected java.lang.String queryText

  The requested Text, especially for simple or field queries

### baseResults

    protected Results baseResults

  Results of a base query.

### baseQuery

    protected Query baseQuery

  The internal Lucene query for the base query.

### baseOperator

    protected int baseOperator

  The operator linking this query to the base query.

### sortSpecification

    protected SortSpecification sortSpecification

  The sort specification for this query.

### filter

    protected Filter filter

  The filter for this query.

### luceneQuery

    protected org.apache.lucene.search.Query luceneQuery

  The internal Lucene query for this query.

### cachedQuery

    protected CachingRewrittenQueryWrapper cachedQuery

  The internal Lucene query wrapper for term collection/highlighting

Constructor Detail

### AbstractQuery

    public AbstractQuery()

Method Detail

### setUp

    public void setUp(SearchLocations sLocs,
                      org.apache.lucene.search.Query lquery)
               throws SDXException

  Specified by:
    `setUp` in interface `Query`
  Throws:
    `SDXException`

### setLuceneQuery

    public void setLuceneQuery(org.apache.lucene.search.Query lquery)

  Specified by:
    `setLuceneQuery` in interface `Query`

### getLuceneQuery

    public org.apache.lucene.search.Query getLuceneQuery()

  Returns the internal Lucene query for this query.

  Specified by:
    `getLuceneQuery` in interface `Query`

### getCachedQuery

    public org.apache.lucene.search.Query getCachedQuery()

  Specified by:
    `getCachedQuery` in interface `Query`

### execute

    public Results execute()
                    throws SDXException

  Executes the query and return results.

  Specified by:
    `execute` in interface `Query`
  Throws:
    `SDXException`

### getOperator

    public static int getOperator(java.lang.String str)

  Returns a query operator from a given string representation.

  The values accepted are :

  1. `and` ; `et` for the logical AND operator
  2. `or` ; `ou` for the logical OR operator
  3. `not` ; `sauf` for the logical NOT operator

  Parameters:
    `str` - The string representation of the operator.
  Returns:
    The operator ; if the string representation does'nt match any operator, OPERATOR_AND is returned.

### addBaseQuery

    public void addBaseQuery(Results results,
                             int operator)

  Adds a base query for this query.

  A base query is another query, given by its search results, that will be combined with the current query with a logical operator (AND, OR or NOT).

  Using the AND operator is equivalent to "searching within results". Using the OR operator lets one extend a query. Using the NOT operator lets one eclude some previous results.

  Specified by:
    `addBaseQuery` in interface `Query`
  Parameters:
    `results` - Results from the base query.
    `operator` - The operator to use.

### addBaseQuery

    public void addBaseQuery(Query query,
                             int operator)

  Description copied from interface: `Query`
  Adds a base query to the current query

  Specified by:
    `addBaseQuery` in interface `Query`
  Parameters:
    `query` - The query object
    `operator` - The operator linking the query with the base query

### addSortSpecification

    public void addSortSpecification(SortSpecification ss)

  Adds a sort specification for this query.

  Specified by:
    `addSortSpecification` in interface `Query`
  Parameters:
    `ss` - The sort specification.

### addFilter

    public void addFilter(Filter filter)

  Adds a filter for this query.

  Specified by:
    `addFilter` in interface `Query`
  Parameters:
    `filter` - The filter to add.

### prepare

    public Filter prepare()

  Prepares a query before execution.

  Queries needing a specifc action can override this method that only returns the current filter.

  Specified by:
    `prepare` in interface `Query`
  Returns:
    A filter defined for this query.

### addAttributesLucene

    protected org.xml.sax.helpers.AttributesImpl addAttributesLucene(org.xml.sax.helpers.AttributesImpl atts)
                                                              throws org.xml.sax.SAXException

  Factorization of *Query.toSax() components

  Parameters:
    `atts` - current atts to had attributes
  Throws:
    `org.xml.sax.SAXException`

### addAttributesText

    protected org.xml.sax.helpers.AttributesImpl addAttributesText(org.xml.sax.helpers.AttributesImpl atts)
                                                            throws org.xml.sax.SAXException

  Factorization of *Query.toSax() components

  Parameters:
    `atts` - current atts to had attributes
  Throws:
    `org.xml.sax.SAXException`

### toSAX

    public abstract void toSAX(org.xml.sax.ContentHandler hdl)
                        throws org.xml.sax.SAXException

  Formats a query in XML.

  Specified by:
    `toSAX` in interface `org.apache.excalibur.xml.sax.XMLizable`
  Overrides:
    `toSAX` in class `AbstractSdxObject`
  Parameters:
    `hdl` - A content handler to receive XML data.
  Throws:
    `org.xml.sax.SAXException`

### setSearchLocations

    protected void setSearchLocations(SearchLocations sLocs)
                               throws SDXException

  Sets the SearchLocations object

  Parameters:
    `sLocs` - The SearchLocations object
  Throws:
    `SDXException`

### setUp

    public void setUp()

  Does nothing here, please see subclasses

### getSearchLocations

    public SearchLocations getSearchLocations()

  Specified by:
    `getSearchLocations` in interface `Query`

### getClassNameSuffix

    protected java.lang.String getClassNameSuffix()

  Description copied from class: `AbstractSdxObject`
  Sub classes should element this method to return their class name suffix for SAX output

  Specified by:
    `getClassNameSuffix` in class `AbstractSdxObject`

### getBoost

    public float getBoost()

  Description copied from interface: `Query`
  Returns the boost on the query.

  This method returns the boost on the query.

  Specified by:
    `getBoost` in interface `Query`
  Returns:
    the boost value by a float.

### setBoost

    public void setBoost(float boost)

  Description copied from interface: `Query`
  Change the boost on the query.

  This method changes the boost on the query to make it more significant.

  Specified by:
    `setBoost` in interface `Query`

### setBoost

    public void setBoost(java.lang.String boost)

  Description copied from interface: `Query`
  Change the boost on the query.

  This method changes the boost on the query to make it more significant. If the String is not a valid float, no changes occur.

  Specified by:
    `setBoost` in interface `Query`

### initToSax

    protected boolean initToSax()

  Description copied from class: `AbstractSdxObject`
  Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML

  Specified by:
    `initToSax` in class `AbstractSdxObject`

### initVolatileObjectsToSax

    protected void initVolatileObjectsToSax()

  Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML Some objects need to be refresh each time a toSAX is called

  Specified by:
    `initVolatileObjectsToSax` in class `AbstractSdxObject`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2007 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.