org.apache.jackrabbit.core.query.lucene
Class SharedFieldSortComparator

java.lang.Object
  extended byorg.apache.lucene.search.SortComparator
      extended byorg.apache.jackrabbit.core.query.lucene.SharedFieldSortComparator
All Implemented Interfaces:
Serializable, org.apache.lucene.search.SortComparatorSource

public class SharedFieldSortComparator
extends org.apache.lucene.search.SortComparator

Implements a SortComparator which knows how to sort on a lucene field that contains values for multiple properties.

Important: The ScoreDocComparator returned by newComparator(org.apache.lucene.index.IndexReader, java.lang.String) does not implement the contract for ScoreDocComparator.sortValue(ScoreDoc) properly. The method will always return an empty String to save memory consumption on large property ranges. Those values are only of relevance when queries are executed with a MultiSearcher, which is currently not the case in Jackrabbit.

See Also:
Serialized Form

Constructor Summary
SharedFieldSortComparator(String fieldname)
          Creates a new SharedFieldSortComparator for a given shared field.
SharedFieldSortComparator(String fieldname, boolean createComparatorValues)
          Creates a new SharedFieldSortComparator for a given shared field.
 
Method Summary
protected  Comparable getComparable(String termtext)
           
 org.apache.lucene.search.ScoreDocComparator newComparator(org.apache.lucene.index.IndexReader reader, String propertyName)
          Creates a new ScoreDocComparator for an embedded propertyName and a reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SharedFieldSortComparator

public SharedFieldSortComparator(String fieldname)
Creates a new SharedFieldSortComparator for a given shared field.

Parameters:
fieldname - the shared field.

SharedFieldSortComparator

public SharedFieldSortComparator(String fieldname,
                                 boolean createComparatorValues)
Creates a new SharedFieldSortComparator for a given shared field.

Parameters:
fieldname - the shared field.
createComparatorValues - if true creates values for the ScoreDocComparators.
See Also:
#createComparatorValues
Method Detail

newComparator

public org.apache.lucene.search.ScoreDocComparator newComparator(org.apache.lucene.index.IndexReader reader,
                                                                 String propertyName)
                                                          throws IOException
Creates a new ScoreDocComparator for an embedded propertyName and a reader.

Parameters:
reader - the index reader.
propertyName - the name of the property to sort.
Returns:
a ScoreDocComparator for the
Throws:
IOException

getComparable

protected Comparable getComparable(String termtext)
Throws:
UnsupportedOperationException - always.


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.