com.atlassian.jira.issue.search
Interface LuceneFieldSorter<T>

All Known Subinterfaces:
StatisticsMapper<T>
All Known Implementing Classes:
AbstractConstantStatisticsMapper, AbstractCustomFieldStatisticsMapper, AbstractDateStatisticsMapper, AssigneeStatisticsMapper, CachingStatisticsMapper, ComponentStatisticsMapper, CustomFieldLabelsStatisticsMapper, CustomFieldProjectStatisticsMapper, CustomFieldUserStatisticsMapper, CustomFieldVersionStatisticsMapper, DateFieldSorter, DatePeriodStatisticsMapper, FixForVersionStatisticsMapper, GroupPickerStatisticsMapper, IssueKeyStatisticsMapper, IssueTypeStatisticsMapper, LabelsStatisticsMapper, LongFieldStatisticsMapper, NumericFieldStatisticsMapper, PriorityStatisticsMapper, ProjectSelectStatisticsMapper, ProjectStatisticsMapper, RaisedInVersionStatisticsMapper, ReporterStatisticsMapper, ResolutionStatisticsMapper, ReversePriorityStatisticsMapper, SecurityLevelStatisticsMapper, SelectStatisticsMapper, StatisticsMapperWrapper, StatusStatisticsMapper, SubTaskStatisticsMapper, TextFieldSorter, TimeTrackingStatisticsMapper, UserPickerStatisticsMapper, UserStatisticsMapper, VersionStatisticsMapper, VotesStatisticsMapper

public interface LuceneFieldSorter<T>

Implementations of this interface are used to sort Lucene search results of Issue Documents.

NOTE: instances of this interface are cached by Lucene and are REUSED to sort multiple Lucene search results. The Comparator returned by the getComparator() method could be used by Lucene from multiple threads at once.

Therefore, the implementations of this interface MUST implement the Object.equals(Object) and Object.hashCode() methods correctly to ensure that Lucene can find the implementations of this class in its cache and reuse it, rather than make the cache grow indefinitely. (Unfortunately the Lucene cache is rather primitive at the moment, and is not bound).

Also, ensure that the Comparator returned by the getComparator() method is thread safe.

As instances of this and the Comparator returned by this object are cached and reused by Lucene to sort multiple search results, the best thing to do is to ensure the implementations of this interface and the Comparator that is returned are immutable and that the equals(Object) and hashCode() methods respect the state of the object.


Method Summary
 boolean equals(java.lang.Object obj)
          As this object is used as a key in a cache, this method must be provided and respect all internal state.
 java.util.Comparator<T> getComparator()
          A comparator that can be used to order objects returned by getValueFromLuceneField(String).
 java.lang.String getDocumentConstant()
          Get the constant that this field is indexed with.
 T getValueFromLuceneField(java.lang.String documentValue)
          Convert the lucene document field back to the object that you wish to use to display it.
 int hashCode()
          As this object is used as a key in a cache, this method must be provided and respect all internal state.
 

Method Detail

getDocumentConstant

java.lang.String getDocumentConstant()
Get the constant that this field is indexed with.

See Also:
IssueDocument, CustomFieldSearcher

getValueFromLuceneField

T getValueFromLuceneField(java.lang.String documentValue)
Convert the lucene document field back to the object that you wish to use to display it.

eg. '1000' -> Version 1.

This does the reverse of what IssueDocument does.

For custom fields, the return value will be passed to CustomFieldSearcherModuleDescriptor.getStatHtml(com.atlassian.jira.issue.fields.CustomField, Object, String)

Parameters:
documentValue - The value of the field in the lucene index
Returns:
The value that will be passed to the display

getComparator

java.util.Comparator<T> getComparator()
A comparator that can be used to order objects returned by getValueFromLuceneField(String).

The Comparator must be reentrant as it could be used by Lucene from multiple threads at once.


equals

boolean equals(java.lang.Object obj)
As this object is used as a key in a cache, this method must be provided and respect all internal state.

See the class javadoc entry for more details.

Overrides:
equals in class java.lang.Object

hashCode

int hashCode()
As this object is used as a key in a cache, this method must be provided and respect all internal state.

See the class javadoc entry for more details.

Overrides:
hashCode in class java.lang.Object


Copyright © 2002-2010 Atlassian. All Rights Reserved.