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 SortSpecification

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

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

public class SortSpecification
extends AbstractSdxObject
implements java.util.Comparator

Indications for sorting of search results. The specifications of sorting are an ordered list of sort keys (SortKey class).

Nested Class Summary

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

Field Summary
`static java.lang.String` | `CLASS_NAME_SUFFIX`
`static int` | `SORT_ORDER_ASCENDANT` int to specifiy and an ascending sort.
`static int` | `SORT_ORDER_DESCENDANT` int to specifiy and an descending sort.
`static java.lang.String` | `SORT_RANKING` The field for the sorting by relevance.
`static int` | `SORT_UNLIMITED` The int to specify an unlimited sort

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.utils.Encodable
`DEFAULT_ENCODING`

Constructor Summary
`SortSpecification()` Build a specification for sorting.

Method Summary
`void` | `addSortKey(Field field)` Adds an ascending sort key to the specification by a field.
`void` | `addSortKey(Field field, int order)` Adds a sort key to the specification by a field and an order.
`void` | `addSortKey(java.lang.String fieldName, int order, SearchLocations locations)` Adds a sort key to the specification, a searchLocation is needed to obtains information about locale and analysers
`void` | `addSortKey(java.lang.String fieldName, SearchLocations locations)` Adds a sort key to the specification, a searchLocation is needed to obtains information about locale and analysers
`int` | `compare(java.lang.Object doc1, java.lang.Object doc2)` Carries out the comparison of two documents with the aim of sorting them .
`protected java.lang.String` | `getClassNameSuffix()` Sub classes should element this method to return their class name suffix for SAX output
`org.apache.lucene.search.Sort` | `getLuceneSort()`
`int` | `getMaxSort()`
`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
`void` | `setMaxSort(int max_sort)` Set the maximum number of documents to sort.
`void` | `setMaxSort(java.lang.String max_sort)` Set the maximum number of documents to sort.
`ResultDocuments` | `sortResults(org.apache.lucene.search.Hits hits)` Sorts the search results.
`ResultDocuments` | `sortResults(ResultDocuments res)` Sorts the search results.
`void` | `toSAX(org.xml.sax.ContentHandler hdl)` Returns an XML representation of this sort specification.

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 java.util.Comparator
`equals`

Field Detail

### CLASS_NAME_SUFFIX

    public static final java.lang.String CLASS_NAME_SUFFIX

See Also:
  Constant Field Values

### SORT_ORDER_ASCENDANT

    public static final int SORT_ORDER_ASCENDANT

  int to specifiy and an ascending sort.

  See Also:
    Constant Field Values

### SORT_ORDER_DESCENDANT

    public static final int SORT_ORDER_DESCENDANT

  int to specifiy and an descending sort.

  See Also:
    Constant Field Values

### SORT_RANKING

    public static final java.lang.String SORT_RANKING

  The field for the sorting by relevance.

  See Also:
    Constant Field Values

### SORT_UNLIMITED

    public static final int SORT_UNLIMITED

  The int to specify an unlimited sort

  See Also:
    Constant Field Values

Constructor Detail

### SortSpecification

    public SortSpecification()
                      throws SDXException

  Build a specification for sorting.

Method Detail

### addSortKey

    public void addSortKey(Field field,
                           int order)
                    throws SDXException

  Adds a sort key to the specification by a field and an order.

  Parameters:
    `field` - The field.
    `order` - The order.
  Throws:
    `SDXException`

### addSortKey

    public void addSortKey(Field field)
                    throws SDXException

  Adds an ascending sort key to the specification by a field.

  Parameters:
    `field` - The field.
  Throws:
    `SDXException`

### addSortKey

    public void addSortKey(java.lang.String fieldName,
                           int order,
                           SearchLocations locations)
                    throws SDXException

  Adds a sort key to the specification, a searchLocation is needed to obtains information about locale and analysers

  Parameters:
    `fieldName` - The field.
    `order` - order
    `locations` -
  Throws:
    `SDXException`

### addSortKey

    public void addSortKey(java.lang.String fieldName,
                           SearchLocations locations)
                    throws SDXException

  Adds a sort key to the specification, a searchLocation is needed to obtains information about locale and analysers

  Parameters:
    `fieldName` - The field.
    `locations` -
  Throws:
    `SDXException`

### sortResults

    public ResultDocuments sortResults(org.apache.lucene.search.Hits hits)
                                throws SDXException

  Sorts the search results.

  Parameters:
    `hits` - The search hits
  Throws:
    `SDXException`

### sortResults

    public ResultDocuments sortResults(ResultDocuments res)
                                throws SDXException,
                                       java.io.IOException

  Sorts the search results.

  Parameters:
    `res` - The result documents
  Throws:
    `SDXException`
    `java.io.IOException`

### compare

    public int compare(java.lang.Object doc1,
                       java.lang.Object doc2)

  Carries out the comparison of two documents with the aim of sorting them .

  Specified by:
    `compare` in interface `java.util.Comparator`
  Parameters:
    `doc1` - The first document.
    `doc2` - The second document.

### toSAX

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

  Returns an XML representation of this sort specification.

  Specified by:
    `toSAX` in interface `org.apache.excalibur.xml.sax.XMLizable`
  Overrides:
    `toSAX` in class `AbstractSdxObject`
  Parameters:
    `hdl` - The ContentHandler to feed with events.
  Throws:
    `org.xml.sax.SAXException`

### getLuceneSort

    public org.apache.lucene.search.Sort getLuceneSort()

### getMaxSort

    public int getMaxSort()

  Returns:
    the maximum number of documents to sort. Set as SORT_UNLIMITED if unlimited.

### setMaxSort

    public void setMaxSort(int max_sort)

  Set the maximum number of documents to sort. Set as SORT_UNLIMITED if unlimited.

### setMaxSort

    public void setMaxSort(java.lang.String max_sort)

  Set the maximum number of documents to sort. Set as SORT_UNLIMITED if unlimited. Convenience method to parse a String to an int and handle the NumberformatException.

### 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`

### 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-2003 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.