Class CollectionUtils

java.lang.Object
com.webmethods.caf.faces.data.CollectionUtils

public class CollectionUtils extends Object
Utility functions for manipulating collections.
  • Constructor Details

    • CollectionUtils

      public CollectionUtils()
  • Method Details

    • sort

      public static void sort(List<?> list, boolean ascending)
      Sorts the specified list by comparing the items in the list using the Comparable interface. If items in the list are Strings, uses a locale-appropriate Collator for comparisons.
      Parameters:
      list - List to sort. Never null.
      ascending - True to sort a-z/1-100/etc (natural order); false to sort z-a/100-1/etc (reverse order).
    • sort

      public static void sort(List<?> list, ISortInfo sort, String rowVariable)
      Sorts the specified list using the specified SortInfo. The keys of the SortInfo object should be ValueBinding objects which resolve to properties of the current list item. When the ValueBinding objects resolve to String properties, a locale-appropriate Collator is used for comparisons; otherwise the Comparable interface is used.
      Parameters:
      list - List to sort. Never null.
      sort - Sort-info to use to sort the list. The keys of this parameter should be ValueExpression objects which resolves to properties of the current list item. For example, if the rowVariable is "item" and the sort-info has two keys, the first of which is "#{item.foo}" and the second "#{item.bar}", the list items will be compared first with the "foo" property of each item, and then, where the "foo" item property value of two items is equal, the "bar" property of each item.
      rowVariable - Name of row variable used to represent the current list item in the value-binding expression.
    • sort

      @Deprecated public static void sort(List<?> list, ValueBinding binding, boolean ascending, String rowVariable)
      Sorts the specified list using the specified ValueBinding to compare items in the list. If the ValueBinding resolves to a String property, uses a locale-appropriate Collator for comparisons; otherwise uses the Comparable interface.
      Parameters:
      list - List to sort. Never null.
      binding - Value-binding to use to compare items in a list. For example, if the rowVariable is "item" and this value-binding is "#{item.foo}", the list items will be compared using the "foo" property of each item.
      ascending - True to sort a-z/1-100/etc (natural order); false to sort z-a/100-1/etc (reverse order).
      rowVariable - Name of row variable used to represent the current list item in the value-binding expression.
    • sort

      public static void sort(List<?> list, ValueExpression binding, boolean ascending, String rowVariable)
      Sorts the specified list using the specified ValueBinding to compare items in the list. If the ValueBinding resolves to a String property, uses a locale-appropriate Collator for comparisons; otherwise uses the Comparable interface.
      Parameters:
      list - List to sort. Never null.
      binding - Value-binding to use to compare items in a list. For example, if the rowVariable is "item" and this value-binding is "#{item.foo}", the list items will be compared using the "foo" property of each item.
      ascending - True to sort a-z/1-100/etc (natural order); false to sort z-a/100-1/etc (reverse order).
      rowVariable - Name of row variable used to represent the current list item in the value-binding expression.
    • filter

      public static void filter(Collection<?> collection, String filter, CollectionUtils.IFilterableValueDecorator valueDecorator)
      Removes the items from the specified collection whose value does not match the filter.
      Parameters:
      collection - Items to filter. The collection will be iterated, and the iterator's remove() method will be called for each item that does not match the filter.
      filter - Expression to use to filter the collection. The filter expression uses the standard commonsearch keyword rules (* = wildcard, space = and, quotes = exact phrase).
      valueDecorator - Decorator to use to calculate the value on which to filter for each item in the collection.
    • filter

      public static void filter(Collection<?> collection, CollectionUtils.FilterExpression filter, CollectionUtils.IFilterableValueDecorator valueDecorator)
      Removes the items from the specified collection whose value does not match the filter.
      Parameters:
      collection - Items to filter. The collection will be iterated, and the iterator's remove() method will be called for each item that does not match the filter.
      filter - Expression to use to filter the collection. The filter expression uses the standard commonsearch keyword rules (* = wildcard, space = and, quotes = exact phrase).
      valueDecorator - Decorator to use to calculate the value on which to filter for each item in the collection.