Package com.webmethods.caf.faces.data
Class CollectionUtils
java.lang.Object
com.webmethods.caf.faces.data.CollectionUtils
Utility functions for manipulating collections.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Filter expression constructed by a string for use byfilter(Collection, FilterExpression, IFilterableValueDecorator)
.static interface
Filter value decorator for use byfilter(Collection, FilterExpression, IFilterableValueDecorator)
.static class
Deprecated.static class
Filter value decorator for table rows, using a binding expression to calculate the value.static class
Filter value decorator forISelectItemProvider
s. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
filter
(Collection<?> collection, CollectionUtils.FilterExpression filter, CollectionUtils.IFilterableValueDecorator valueDecorator) Removes the items from the specified collection whose value does not match the filter.static void
filter
(Collection<?> collection, String filter, CollectionUtils.IFilterableValueDecorator valueDecorator) Removes the items from the specified collection whose value does not match the filter.static void
Sorts the specified list by comparing the items in the list using theComparable
interface.static void
Sorts the specified list using the specifiedSortInfo
.static void
sort
(List<?> list, ValueExpression binding, boolean ascending, String rowVariable) Sorts the specified list using the specifiedValueBinding
to compare items in the list.static void
sort
(List<?> list, ValueBinding binding, boolean ascending, String rowVariable) Deprecated.usesort(List, ValueExpression, boolean, String)
instead
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
sort
Sorts the specified list by comparing the items in the list using theComparable
interface. If items in the list areString
s, uses a locale-appropriateCollator
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
Sorts the specified list using the specifiedSortInfo
. The keys of theSortInfo
object should beValueBinding
objects which resolve to properties of the current list item. When theValueBinding
objects resolve toString
properties, a locale-appropriateCollator
is used for comparisons; otherwise theComparable
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 beValueExpression
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) Deprecated.usesort(List, ValueExpression, boolean, String)
insteadSorts the specified list using the specifiedValueBinding
to compare items in the list. If theValueBinding
resolves to aString
property, uses a locale-appropriateCollator
for comparisons; otherwise uses theComparable
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 specifiedValueBinding
to compare items in the list. If theValueBinding
resolves to aString
property, uses a locale-appropriateCollator
for comparisons; otherwise uses theComparable
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'sremove()
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'sremove()
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.
-
CollectionUtils.RowValueExpressionFilterableValueDecorator
instead