com.atlassian.jira.issue.statistics.util
Class StatisticsMapperWrapper

java.lang.Object
  extended by com.atlassian.jira.issue.statistics.util.StatisticsMapperWrapper
All Implemented Interfaces:
LuceneFieldSorter, StatisticsMapper
Direct Known Subclasses:
CachingStatisticsMapper

public class StatisticsMapperWrapper
extends java.lang.Object
implements StatisticsMapper

Provides a convenient implementation of the StatisticsMapper interface that can be subclassed by developers wishing to adapt the request to a mapper. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped statisticsMapper object.


Constructor Summary
StatisticsMapperWrapper(StatisticsMapper statisticsMapper)
           
 
Method Summary
 java.util.Comparator getComparator()
          A comparator that can be used to order objects returned by LuceneFieldSorter.getValueFromLuceneField(String).
 java.lang.String getDocumentConstant()
          Get the constant that this field is indexed with.
 SearchRequest getSearchUrlSuffix(java.lang.Object value, SearchRequest searchRequest)
          Get a suffix for the issue navigator, which allows for filtering on this value.
 java.lang.Object getValueFromLuceneField(java.lang.String documentValue)
          Convert the lucene document field back to the object that you wish to use to display it.
 boolean isFieldAlwaysPartOfAnIssue()
          Check if the field is always part of an issues data.
 boolean isValidValue(java.lang.Object value)
          Check whether this value is valid for this particular search.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.jira.issue.search.LuceneFieldSorter
equals, hashCode
 

Constructor Detail

StatisticsMapperWrapper

public StatisticsMapperWrapper(StatisticsMapper statisticsMapper)
Method Detail

isValidValue

public boolean isValidValue(java.lang.Object value)
Description copied from interface: StatisticsMapper
Check whether this value is valid for this particular search. This is useful if you do not wish to display all the values that are indexed (eg - only show released versions)

Specified by:
isValidValue in interface StatisticsMapper
Parameters:
value - This is the same value that will be returned from LuceneFieldSorter.getValueFromLuceneField(String)
Returns:
true if this value is valid for this particular search

isFieldAlwaysPartOfAnIssue

public boolean isFieldAlwaysPartOfAnIssue()
Description copied from interface: StatisticsMapper
Check if the field is always part of an issues data. This should only return false in the case of a custom field where the value does not have to be set for each issue.

Specified by:
isFieldAlwaysPartOfAnIssue in interface StatisticsMapper
Returns:
true if this mapper will always be part of an issues data

getSearchUrlSuffix

public SearchRequest getSearchUrlSuffix(java.lang.Object value,
                                        SearchRequest searchRequest)
Description copied from interface: StatisticsMapper
Get a suffix for the issue navigator, which allows for filtering on this value.

eg. a project field would return a SearchRequest object who's getQueryString method will produce pid=10240

Note that values returned from implementations should return values that are URLEncoded.

Specified by:
getSearchUrlSuffix in interface StatisticsMapper
Parameters:
value - This is the same value that will be returned from LuceneFieldSorter.getValueFromLuceneField(String)
searchRequest - is the search request that should be used as the base of the newly generated SearchRequest object. If this parameter is null then the return type will also be null.
Returns:
a SearchRequest object that will generate the correct issue navigator url to search the correct statistics set, null otherwise.
See Also:
URLEncoder.encode(String)

getDocumentConstant

public java.lang.String getDocumentConstant()
Description copied from interface: LuceneFieldSorter
Get the constant that this field is indexed with.

Specified by:
getDocumentConstant in interface LuceneFieldSorter
See Also:
IssueDocument, CustomFieldSearcher

getValueFromLuceneField

public java.lang.Object getValueFromLuceneField(java.lang.String documentValue)
Description copied from interface: LuceneFieldSorter
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)

Specified by:
getValueFromLuceneField in interface LuceneFieldSorter
Parameters:
documentValue - The value of the field in the lucene index
Returns:
The value that will be passed to the display

getComparator

public java.util.Comparator getComparator()
Description copied from interface: LuceneFieldSorter
A comparator that can be used to order objects returned by LuceneFieldSorter.getValueFromLuceneField(String).

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

Specified by:
getComparator in interface LuceneFieldSorter


Copyright © 2002-2010 Atlassian. All Rights Reserved.