Jive API (3.0.13) Core Javadocs

com.jivesoftware.community
Class QuestionFilter

java.lang.Object
  extended by com.jivesoftware.community.QuestionFilter

public class QuestionFilter
extends Object

Filters and sorts lists of questions from QuestionManager.


Nested Class Summary
static class QuestionFilter.SortField
          Type-safe enumeration for field that be sorted on.
 
Field Summary
static int ASCENDING
          Ascending sort (ie 3, 4, 5...).
static int DESCENDING
          Descending sort (ie 3, 2, 1...).
static int NULL_INT
          An integer value that represents NULL.
 
Constructor Summary
QuestionFilter()
          Constructs a new QuestionFilter.
 
Method Summary
 void addProperty(String name, String value)
          Adds a property to the list of properties that will be filtered on.
 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.
 Object clone()
          Clones a ResultFilter
 boolean equals(Object o)
           
 Date getCreationDateRangeMax()
          Returns a date that represents the upper boundry for messages or threads to be selected by the result filter.
 Date getCreationDateRangeMin()
          Returns the creation date that represents the lower boundary for messages or threads to be filtered on.
 int getNumResults()
          Returns the max number of results that should be returned.
 int getPropertyCount()
          Returns the number of properties that results will be filtered on.
 String getPropertyName(int index)
          Returns the name of the property at the specified index in the list of properties to be filtered on.
 String getPropertyValue(int index)
          Returns the value of the property at the specified index in the list of properties to be filtered on.
 Date getResolutionDateRangeMax()
          Returns a date that represents the upper boundry for the resolution date of questions to be selected by the result filter.
 Date 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.
 QuestionFilter.SortField getSortField()
          Returns the currently selected sort field.
 int getSortOrder()
          Returns the sort order, which will be ASCENDING for ascending sorting, or DESCENDING for descending sorting.
 String getSortPropertyName()
          Returns the name of the extended property that will be sorted on.
 int getStartIndex()
          Returns the index of the first result to return.
 long getUserID()
          Returns the ID of the creator of questions that results will be filtered on.
 int hashCode()
           
 boolean isGroupByContainer()
          Returns true if results will be grouped by community.
 void removeResolutionState(Question.State resolutionState)
          Removes a resolution state from the set of states that will be included in filtered results.
 void setCreationDateRangeMax(Date creationDateRangeMax)
          Sets a date that represents the upper boundry for messages or threads to be selected by the result filter.
 void setCreationDateRangeMin(Date creationDateRangeMin)
          Sets the date that represents the lower boundary for messages or threads to be selected by the result filter.
 void setGroupByContainer(boolean groupByContainer)
          Sets whether to group results by community.
 void setNumResults(int numResults)
          Sets the limit on the number of results to be returned.
 void setResolutionDateRangeMax(Date resolutionnDateRangeMax)
          Sets a date that represents the upper boundry for the resolution date of questions to be selected by the result filter.
 void setResolutionDateRangeMin(Date resolutionDateRangeMin)
          Sets a date that represents the lower boundary for messages or threads to be selected by the result filter.
 void setSortField(QuestionFilter.SortField sortField)
          Sets the sort field to use.
 void setSortOrder(int sortOrder)
          Sets the sort type.
 void setSortPropertyName(String sortPropertyName)
          Sets the property name to sort on.
 void setStartIndex(int startIndex)
          Sets the index of the first result to return.
 void setUserID(long userID)
          Sets the creator of questions that results will be filtered on.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DESCENDING

public static final int DESCENDING
Descending sort (ie 3, 2, 1...).

See Also:
Constant Field Values

ASCENDING

public static final int ASCENDING
Ascending sort (ie 3, 4, 5...).

See Also:
Constant Field Values

NULL_INT

public static final int NULL_INT
An integer value that represents NULL. The actual value is Integer.MAX_VALUE - 123 (an arbitrary number that has a very low probability of actually being selected by a user as a valid value).

See Also:
Constant Field Values
Constructor Detail

QuestionFilter

public QuestionFilter()
Constructs a new QuestionFilter. By default, all questions pass the filter.

Method Detail

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.


getUserID

public long getUserID()
Returns the ID of the creator of questions that results will be filtered on. This method will return -1 if no user to filter on has been specified.

Returns:
the user that results will be filtered on.

setUserID

public void setUserID(long userID)
Sets the creator of questions that results will be filtered on. To avoid filtering on user, pass in null (default value).

Parameters:
userID - the user to filter on.

addProperty

public void addProperty(String name,
                        String value)
Adds a property to the list of properties that will be filtered on. For a message or thread to pass the property filter: For example, say that we have a message with extended properties "color" and "size" with the values "green" and "big". If we create a result filter and specify that we should filter on "color=green" and "size=small", the hypothetical message will be filtered out since the size property values don't match.

Parameters:
name - the name of the property to filter on.
value - the value of the property that results must match.

getPropertyCount

public int getPropertyCount()
Returns the number of properties that results will be filtered on.

Returns:
the number of properties that results will be filtered on.

getPropertyName

public String getPropertyName(int index)
Returns the name of the property at the specified index in the list of properties to be filtered on. If the index is invalid, null will be returned.

Returns:
the name of the property at the specified index in the property filter list.

getPropertyValue

public String getPropertyValue(int index)
Returns the value of the property at the specified index in the list of properties to be filtered on. If the index is invalid, null will be returned.

Returns:
the value of the property at the specified index in the property filter list.

getCreationDateRangeMin

public Date getCreationDateRangeMin()
Returns the creation date that represents the lower boundary for messages or threads to be filtered on. If this value has not been set, the method will return null.

Returns:
a Date representing the lower bound for creation dates to filter on.

setCreationDateRangeMin

public void setCreationDateRangeMin(Date creationDateRangeMin)
Sets the 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 creation date selected.

Setting a date range for a ResultFilter 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:
creationDateRangeMin - Date representing the filter lowest value of the creation date to be selected.

getCreationDateRangeMax

public Date getCreationDateRangeMax()
Returns a date that represents the upper boundry for messages or threads 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 latest creation date selected.

Returns:
a Date representing the filter highest value of the creation date to be selected.

setCreationDateRangeMax

public void setCreationDateRangeMax(Date creationDateRangeMax)
Sets a date that represents the upper boundry 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 latest creation 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:
creationDateRangeMax - Date representing the filter lowest value of the creation date range.

getResolutionDateRangeMin

public Date 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:
a Date representing the filter lowest value of the resolution date range.

setResolutionDateRangeMin

public void setResolutionDateRangeMin(Date 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 - Date representing the filter lowest value of the modified date to be selected.

getResolutionDateRangeMax

public Date 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:
a Date representing the highest value of the resolution date to be selected by the filter.

setResolutionDateRangeMax

public void setResolutionDateRangeMax(Date 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 - Date representing the filter lowest value of the modified date range.

getSortField

public QuestionFilter.SortField getSortField()
Returns the currently selected sort field. The default value is QuestionFilter.SortField.creation_date. If the sortField is set to QuestionFilter.SortField.extended_property, the name of the property must be set by a subsequent call to setSortPropertyName(String).

Returns:
current sort field.

setSortField

public void setSortField(QuestionFilter.SortField sortField)
Sets the sort field to use. The default value is QuestionFilter.SortField.creation_date. If the sortField is set to QuestionFilter.SortField.extended_property, the name of the property must be set by a subsequent call to setSortPropertyName(String).

Parameters:
sortField - the field that will be used for sorting.

getSortPropertyName

public String getSortPropertyName()
Returns the name of the extended property that will be sorted on. Returns null if sorting will not be done on a property.

Returns:
the extended property that will be sorted on.

setSortPropertyName

public void setSortPropertyName(String sortPropertyName)
Sets the property name to sort on. You must also call the setSortField(com.jivesoftware.community.QuestionFilter.SortField) method with QuestionFilter.SortField.extended_property as an argument.

Parameters:
sortPropertyName - the name of the extended property to sort on.

getSortOrder

public int getSortOrder()
Returns the sort order, which will be ASCENDING for ascending sorting, or DESCENDING for descending sorting. Descending sorting is: 3, 2, 1, etc. Ascending sorting is 1, 2, 3, etc.

Returns:
the sort order.

setSortOrder

public void setSortOrder(int sortOrder)
Sets the sort type. Valid arguments are ASCENDING for ascending sorting or DESCENDING for descending sorting. Descending sorting is: 3, 2, 1, etc. Ascending sorting is 1, 2, 3, etc.

Parameters:
sortOrder - the order that results will be sorted in.

isGroupByContainer

public boolean isGroupByContainer()
Returns true if results will be grouped by community.

Returns:
true if results will be grouped by community.

setGroupByContainer

public void setGroupByContainer(boolean groupByContainer)
Sets whether to group results by community.

Parameters:
groupByContainer - true to group results by community.

getNumResults

public int getNumResults()
Returns the max number of results that should be returned. The default value for is NULL_INT, which means there will be no limit on the number of results. This method can be used in combination with setStartIndex(int) to perform pagination of results.

Returns:
the max number of results to return.
See Also:
setStartIndex(int)

setNumResults

public void setNumResults(int numResults)
Sets the limit on the number of results to be returned.

Parameters:
numResults - the number of results to return.

getStartIndex

public int getStartIndex()
Returns the index of the first result to return.

Returns:
the index of the first result which should be returned.

setStartIndex

public void setStartIndex(int startIndex)
Sets the index of the first result to return. For example, if the start index is set to 20, the Iterator returned will start at the 20th result in the query. This method can be used in combination with setNumResults(int) to perform pagination of results.

Parameters:
startIndex - the index of the first result to return.

clone

public Object clone()
Clones a ResultFilter

Overrides:
clone in class Object

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

Jive Product Page

Copyright © 1999-2007 Jive Software.