Package org.jivesoftware.openfire.pubsub
Class PubsubNodeResultFilter
- java.lang.Object
-
- org.jivesoftware.openfire.pubsub.PubsubNodeResultFilter
-
public class PubsubNodeResultFilter extends Object
Filters and sorts lists of pubsub nodes.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.
Factory methods to create common queries are provided for convenience.
- Author:
- Guus der Kinderen
- See Also:
SessionResultFilter
-
-
Field Summary
Fields Modifier and Type Field Description static int
ASCENDING
Ascending sort (ie 3, 4, 5...).static int
DESCENDING
Descending sort (ie 3, 2, 1...).static String
FILTER_AFFILIATE_COUNT
static String
FILTER_ITEM_COUNT
static String
FILTER_NODE_DESCRIPTION
static String
FILTER_NODE_IDENTIFIER
static String
FILTER_NODE_NAME
static String
FILTER_SUBSCRIBER_COUNT
static int
NO_RESULT_LIMIT
Represents no result limit (infinite results).static int
SORT_AFFILIATE_COUNT
static int
SORT_ITEM_COUNT
static int
SORT_NODE_DESCRIPTION
static int
SORT_NODE_IDENTIFIER
static int
SORT_NODE_NAME
static int
SORT_SUBSCRIBER_COUNT
-
Constructor Summary
Constructors Constructor Description PubsubNodeResultFilter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFilter(String filterParam, String filterValue)
Adds a new filter to limit the results that are returned.static PubsubNodeResultFilter
createDefaultSessionFilter()
Creates a default PubsubNodeResultFilter: no filtering with results sorted by node ID (ascending).Predicate<Node>
getFilter()
Returns the filter that limits the results that are returned.String[]
getFilterParams()
Generates a collection of all parameter names that can be used for filtering.int
getNumResults()
Returns the max number of results that should be returned.int
getSortColumnNumber()
Returns the currently selected sort field.Comparator<Node>
getSortComparator()
Returns a comparator that will sort a standard sorted set according to this filter's sort order.int
getSortOrder()
Returns the sort order, which will beASCENDING
for ascending sorting, orDESCENDING
for descending sorting.int
getStartIndex()
Returns the index of the first result to return.void
setNumResults(int numResults)
Sets the limit on the number of results to be returned.void
setSortColumnNumber(int sortColumnNumber)
Sets the sort field to use.void
setSortOrder(int sortOrder)
Sets the sort order.void
setStartIndex(int startIndex)
Sets the index of the first result to return.
-
-
-
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
-
NO_RESULT_LIMIT
public static final int NO_RESULT_LIMIT
Represents no result limit (infinite results).- See Also:
- Constant Field Values
-
SORT_NODE_IDENTIFIER
public static final int SORT_NODE_IDENTIFIER
- See Also:
- Constant Field Values
-
SORT_NODE_NAME
public static final int SORT_NODE_NAME
- See Also:
- Constant Field Values
-
SORT_NODE_DESCRIPTION
public static final int SORT_NODE_DESCRIPTION
- See Also:
- Constant Field Values
-
SORT_ITEM_COUNT
public static final int SORT_ITEM_COUNT
- See Also:
- Constant Field Values
-
SORT_AFFILIATE_COUNT
public static final int SORT_AFFILIATE_COUNT
- See Also:
- Constant Field Values
-
SORT_SUBSCRIBER_COUNT
public static final int SORT_SUBSCRIBER_COUNT
- See Also:
- Constant Field Values
-
FILTER_NODE_IDENTIFIER
public static final String FILTER_NODE_IDENTIFIER
- See Also:
- Constant Field Values
-
FILTER_NODE_NAME
public static final String FILTER_NODE_NAME
- See Also:
- Constant Field Values
-
FILTER_NODE_DESCRIPTION
public static final String FILTER_NODE_DESCRIPTION
- See Also:
- Constant Field Values
-
FILTER_ITEM_COUNT
public static final String FILTER_ITEM_COUNT
- See Also:
- Constant Field Values
-
FILTER_AFFILIATE_COUNT
public static final String FILTER_AFFILIATE_COUNT
- See Also:
- Constant Field Values
-
FILTER_SUBSCRIBER_COUNT
public static final String FILTER_SUBSCRIBER_COUNT
- See Also:
- Constant Field Values
-
-
Method Detail
-
createDefaultSessionFilter
public static PubsubNodeResultFilter createDefaultSessionFilter()
Creates a default PubsubNodeResultFilter: no filtering with results sorted by node ID (ascending).- Returns:
- default PubsubNodeResultFilter.
-
getSortColumnNumber
public int getSortColumnNumber()
Returns the currently selected sort field. The default value isSORT_NODE_IDENTIFIER
.- Returns:
- current sort field.
-
setSortColumnNumber
public void setSortColumnNumber(int sortColumnNumber)
Sets the sort field to use.- Parameters:
sortColumnNumber
- the field that will be used for sorting.
-
getSortOrder
public int getSortOrder()
Returns the sort order, which will beASCENDING
for ascending sorting, orDESCENDING
for descending sorting. The default value isASCENDING
. 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 order. Valid arguments areASCENDING
for ascending sorting, andDESCENDING
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.
-
getNumResults
public int getNumResults()
Returns the max number of results that should be returned. The default value for isNO_RESULT_LIMIT
, which means there will be no limit on the number of results. This method can be used in combination withsetStartIndex(int)
to perform pagination of results.- Returns:
- the max number of results to return or NO_RESULT_LIMIT for no limit
- See Also:
setStartIndex(int)
-
setNumResults
public void setNumResults(int numResults)
Sets the limit on the number of results to be returned. UseNO_RESULT_LIMIT
if you don't want to limit the results returned.- Parameters:
numResults
- the number of results to return or NO_RESULT_LIMIT for no limit
-
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 withsetNumResults(int)
to perform pagination of results.- Parameters:
startIndex
- the index of the first result to return.
-
getSortComparator
public Comparator<Node> getSortComparator()
Returns a comparator that will sort a standard sorted set according to this filter's sort order.- Returns:
- a comparator that sorts Sessions matching the sort order for this filter.
-
getFilterParams
public String[] getFilterParams()
Generates a collection of all parameter names that can be used for filtering.- Returns:
- all filter parameter names.
-
addFilter
public void addFilter(String filterParam, String filterValue)
Adds a new filter to limit the results that are returned. The existing filter conditions are augmented with a new condition. Only results for which the value of a particular parameter matches the provided filter conditions will be result.- Parameters:
filterParam
- The filter parameter name.filterValue
- The filter paramter value.
-
-