Clearspace API (2.5.29) Core Javadocs

com.jivesoftware.community
Class ThreadResultFilter

java.lang.Object
  extended by com.jivesoftware.community.ResultFilter
      extended by com.jivesoftware.community.ThreadResultFilter
Direct Known Subclasses:
BlogPostResultFilter, FeedbackResultFilter, ModerationFilter, TagResultFilter

public class ThreadResultFilter
extends ResultFilter

Filters and sorts lists of ForumThreads and ForumMessages. This allows for a very rich set of possible queries that can be run on forum data. Some examples are: "Show all messages posted in the forum during the last year by a certain user" or "Show all threads in the forum, sorted by their modification date".

The class also supports pagination of results with the setStartIndex(int) and setNumResults(int) methods. If the start index is not set, it will begin at index 0 (the start of results). If the number of results is not set, it will be unbounded and return as many results as available.

By default, result filters will obey the moderation rules as they are set for each community. You can override this behavior by setting a moderation range.

Factory methods to create common queries are provided for convenience.

See Also:
ForumManager.getThreads(JiveContainer ,ThreadResultFilter), ForumManager.getMessages(JiveContainer ,ThreadResultFilter), ForumThread.getMessages(ThreadResultFilter)

Field Summary
 
Fields inherited from class com.jivesoftware.community.ResultFilter
AND_MODE, ASCENDING, CONTAINS_MATCH, DESCENDING, EXACT_MATCH, NULL_INT, OR_MODE
 
Constructor Summary
ThreadResultFilter()
           
 
Method Summary
 void addResolutionState(Question.State resolutionState)
          Adds a resolution state to the set of states that will be included in filtered results.
 void clearResolutionStates()
          Removes all resolution states from the set of states that will be included in filtered results.
static ThreadResultFilter createDefaultMessageFilter()
          Creates a default message ResultFilter: no filtering with results sorted on the message creation date in ascending order.
static ThreadResultFilter createDefaultThreadFilter()
          Creates a default thread ResultFilter: no filtering with results sorted on the thread modification date.
static ThreadResultFilter createDefaultUserMessagesFilter()
          Creates a default user messages ResultFilter: no filtering with results sorted on the message creation date descending (newest messages appear first).
 boolean equals(Object o)
           
 int getModerationRangeMax()
          Returns the moderation value that represents the upper bound for messages or threads to be selected by the result filter.
 int getModerationRangeMin()
          Returns the moderation value that represents the lower boundry for messages or threads to be selected by the result filter.
 int getResolutionDateRangeMax()
          Returns a date that represents the upper boundry for the resolution date of questions to be selected by the result filter.
 int getResolutionDateRangeMin()
          Returns a date that represents the lower boundary for the resolution date of questions to be selected by the result filter.
 Set<Question.State> getResolutionStates()
          Returns the set resolution states that will be included in filtered results.
 boolean getShowModerated()
           
 int getSortField()
          Returns the currently selected sort field.
 int hashCode()
           
 void removeResolutionState(Question.State resolutionState)
          Removes a resolution state from the set of states that will be included in filtered results.
static Date roundDate(Date date, int seconds)
           
static long roundDate(long date, int seconds)
           
 void setModerationRangeMax(int moderationRangeMax)
          Sets the upper bound for the moderation value that will pass the result filter.
 void setModerationRangeMin(int moderationRangeMin)
          Sets the moderation value that represents the lower bound for messages or threads to be selected by the result filter.
 void setResolutionDateRangeMax(int resolutionnDateRangeMax)
          Sets a date that represents the upper boundry for the resolution date of questions to be selected by the result filter.
 void setResolutionDateRangeMin(int resolutionDateRangeMin)
          Sets a date that represents the lower boundary for messages or threads to be selected by the result filter.
 void setShowModerated(boolean showModerated)
           
 void setSortField(int sortField)
          Sets the sort field to use.
 String toString()
           
 
Methods inherited from class com.jivesoftware.community.ResultFilter
addProperty, addProperty, addTag, createDefaultContentFilter, createDefaultRecursiveContentFilter, getCreationDateRangeMax, getCreationDateRangeMin, getModificationDateRangeMax, getModificationDateRangeMin, getNumResults, getPropertyCount, getPropertyMatchType, getPropertyMode, getPropertyName, getPropertyValue, getPropertyValueString, getSortOrder, getSortPropertyName, getStartIndex, getTags, getUserID, isAllTagsRequired, isPerformDistinctCount, isRecursive, setAllTagsRequired, setCreationDateRangeMax, setCreationDateRangeMin, setModificationDateRangeMax, setModificationDateRangeMin, setNumResults, setPerformDistinctCount, setPropertyMode, setRecursive, setSortOrder, setSortPropertyName, setStartIndex, setTags, setUserID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadResultFilter

public ThreadResultFilter()
Method Detail

getShowModerated

public boolean getShowModerated()

setShowModerated

public void setShowModerated(boolean showModerated)

createDefaultThreadFilter

public static ThreadResultFilter createDefaultThreadFilter()
Creates a default thread ResultFilter: no filtering with results sorted on the thread modification date.


createDefaultMessageFilter

public static ThreadResultFilter createDefaultMessageFilter()
Creates a default message ResultFilter: no filtering with results sorted on the message creation date in ascending order.


createDefaultUserMessagesFilter

public static ThreadResultFilter createDefaultUserMessagesFilter()
Creates a default user messages ResultFilter: no filtering with results sorted on the message creation date descending (newest messages appear first).


getSortField

public int getSortField()
Returns the currently selected sort field. The default value is JiveConstants.MODIFICATION_DATE. If the sortField is set to JiveConstants.EXTENDED_PROPERTY, the name of the property must be set by a subsequent call to ResultFilter.setSortPropertyName(String).

Valid sort fields for object types are as follows:

Overrides:
getSortField in class ResultFilter
Returns:
current sort field.

setSortField

public void setSortField(int sortField)
Sets the sort field to use. The default value is JiveConstants.MODIFICATION_DATE. If the sortField is set to JiveConstants.EXTENDED_PROPERTY, the name of the property must be set by a subsequent call to ResultFilter.setSortPropertyName(String).

Valid sort fields for object types are as follows:

Overrides:
setSortField in class ResultFilter
Parameters:
sortField - the field that will be used for sorting.

getModerationRangeMin

public int getModerationRangeMin()
Returns the moderation value that represents the lower boundry for messages or threads to be selected by the result filter. If this value is not set it will return the lowest moderation value allowed and the results filter will be unbounded for the lowest moderation value selected.

For example -- if boolean moderation is being used, the possible values that can be expected of a message are -1 for rejected messages, 0 unapproved messages, and 1 for approved messages. To show messages available for the general public, you would pass this accessor a minimum value of 1 and a maximum value of 1 or higher. To show messages in need of moderation you would pass this accessor a minimum value of 0 and a maximum value of 0. To show messages in need of moderation in the context of threads that are already approved, you would pass this accessor a minumum value of 0 and a maximum value of 1.

Returns:
an int representing the lowest value of the moderation value to be selected by the filter.

setModerationRangeMin

public void setModerationRangeMin(int moderationRangeMin)
Sets the moderation value that represents the lower bound for messages or threads to be selected by the result filter. If this value is not set, the lower bound will default to JiveConstants.FORUM_MODERATION_VISIBLE.

Parameters:
moderationRangeMin - int representing the lowest value of the moderation value range to be selected by the result filter.

getModerationRangeMax

public int getModerationRangeMax()
Returns the moderation value that represents the upper bound for messages or threads to be selected by the result filter. If an upper bound has not been set, this method will return ResultFilter.NULL_INT.

Returns:
the upper bound for moderation values to filter on.

setModerationRangeMax

public void setModerationRangeMax(int moderationRangeMax)
Sets the upper bound for the moderation value that will pass the result filter. If this value is not set, or is set to ResultFilter.NULL_INT there will be no upper bound on moderation values.

Parameters:
moderationRangeMax - the max value of the moderation value range.

getResolutionStates

public Set<Question.State> getResolutionStates()
Returns the set resolution states that will be included in filtered results. By default, all resolution states are included.

Returns:
the set of resolution states that will be included in filtered results.

addResolutionState

public void addResolutionState(Question.State resolutionState)
Adds a resolution state to the set of states that will be included in filtered results.

Parameters:
resolutionState - resolution state.

removeResolutionState

public void removeResolutionState(Question.State resolutionState)
Removes a resolution state from the set of states that will be included in filtered results.

Parameters:
resolutionState - resolution state.

clearResolutionStates

public void clearResolutionStates()
Removes all resolution states from the set of states that will be included in filtered results.


getResolutionDateRangeMin

public int getResolutionDateRangeMin()
Returns a date that represents the lower boundary for the resolution date of questions to be selected by the result filter. If this value is not set it will return null and the results filter will be unbounded for the earliest modified date selected.

Returns:
the lowest value of the resolution date to be selected by the filter.

setResolutionDateRangeMin

public void setResolutionDateRangeMin(int resolutionDateRangeMin)
Sets a date that represents the lower boundary for messages or threads to be selected by the result filter. If this value is not set the results filter will be unbounded for the earliest modified date selected.

Setting a date range for a QuestionFilter is a potential performance bottleneck. For example, if the argument for the date range is "new Date()" then the corresponding database query will map to an accuracy of a particular millesecond in time. This means that the results can't be cached. A better solution is to round dates to the nearest minute, hour, etc (whatever accuracy you need).

Parameters:
resolutionDateRangeMin - the lowest value of the resolution date to be selected by the filter.

getResolutionDateRangeMax

public int getResolutionDateRangeMax()
Returns a date that represents the upper boundry for the resolution date of questions to be selected by the result filter. If this value is not set it will return null and the filter will be unbounded for the resolution date.

Returns:
the highest value of the resolution date to be selected by the filter.

setResolutionDateRangeMax

public void setResolutionDateRangeMax(int resolutionnDateRangeMax)
Sets a date that represents the upper boundry for the resolution date of questions to be selected by the result filter. If this value is not set the filter will be unbounded for the resolution date.

Setting a date range for a QuestionFilter is a potential performance bottleneck. For example, if the argument for the date range is "new Date()" then the corresponding database query will map to an accuracy of a particular millesecond in time. This means that the results can't be cached. A better solution is to round dates to the nearest minute, hour, etc (whatever accuracy you need).

Parameters:
resolutionnDateRangeMax - the highest value of the resolution date to be selected by the filter.

roundDate

public static Date roundDate(Date date,
                             int seconds)
See Also:
DateUtils.roundDate(Date, int)

roundDate

public static long roundDate(long date,
                             int seconds)
See Also:
DateUtils.roundDate(long, int)

equals

public boolean equals(Object o)
Overrides:
equals in class ResultFilter

hashCode

public int hashCode()
Overrides:
hashCode in class ResultFilter

toString

public String toString()
Overrides:
toString in class ResultFilter

Clearspace Project Page

Copyright © 1999-2007 Jive Software.