Class 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
    • Constructor Detail

      • PubsubNodeResultFilter

        public PubsubNodeResultFilter()
    • 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 is SORT_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 be ASCENDING for ascending sorting, or DESCENDING for descending sorting. The default value is ASCENDING. 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 are ASCENDING for ascending sorting, and 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.
      • getNumResults

        public int getNumResults()
        Returns the max number of results that should be returned. The default value for is NO_RESULT_LIMIT, 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 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. Use NO_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 with setNumResults(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.
      • getFilter

        public Predicate<Node> getFilter()
        Returns the filter that limits the results that are returned. By default, all results are returned.
        Returns:
        a predicate used for filtering results.