Class SleUtility


  • public final class SleUtility
    extends Object
    This is a utiltiy class for grouping and sorting lists of entries based on the SLE.

    Note, this class can ONLY be used on parsed feeds, unless you manually add the appropriate SleEntry objects on the items.

    See Also:
    SleEntry
    • Method Detail

      • group

        public static <T extends ExtendableList<T> group​(List<T> values,
                                                           Group[] groups)
        Groups values by the groups from the SLE.
        Parameters:
        values - List of Extendable implementations to group.
        groups - Group fields (from the SimpleListExtension module)
        Returns:
        Grouped list of entries.
      • sort

        public static <T extends ExtendableList<T> sort​(List<T> values,
                                                          Sort sort,
                                                          boolean ascending)
        Sorts a list of values based on a given sort field using a selection sort.
        Parameters:
        values - List of values (implements Extendable) to sort.
        sort - The sort field to sort on.
        ascending - Sort ascending/descending.
        Returns:
        Sorted list of values
      • sortAndGroup

        public static <T extends ExtendableList<T> sortAndGroup​(List<T> values,
                                                                  Group[] groups,
                                                                  Sort sort,
                                                                  boolean ascending)
        Sorts and groups a set of entries.
        Parameters:
        values - List of Extendable implementations.
        groups - Group items to group by.
        sort - Field to sort on.
        ascending - Sort ascending/descending
        Returns:
        Grouped and sorted list of entries.
      • initializeForSorting

        public static void initializeForSorting​(SyndFeed feed)
                                         throws FeedException
        This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries with current SleEntry values for sorting and grouping. NB: This basically does this by re-generating the XML for all the entries then re-parsing them into the SLE data structures. It is a very heavy operation and should not be called frequently!
        Throws:
        FeedException