站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.0.5 API 文档英文版

PropertyComparator (Spring Framework API 2.0) - Spring Framework 2.0.5 API 文档英文版

The Spring Framework

org.springframework.beans.support
Class PropertyComparator

java.lang.Object
  extended by org.springframework.beans.support.PropertyComparator
All Implemented Interfaces:
Comparator

public class PropertyComparator
extends Object
implements Comparator

PropertyComparator performs a comparison of two beans, evaluating the specified bean property via a BeanWrapper.

Since:
19.05.2003
Author:
Juergen Hoeller, Jean-Pierre Pawlak
See Also:
BeanWrapper

Field Summary
protected  Log logger
           
 
Constructor Summary
PropertyComparator(SortDefinition sortDefinition)
          Create a new PropertyComparator for the given SortDefinition.
PropertyComparator(String property, boolean ignoreCase, boolean ascending)
          Create a PropertyComparator for the given settings.
 
Method Summary
 int compare(Object o1, Object o2)
           
 SortDefinition getSortDefinition()
          Return the SortDefinition that this comparator uses.
static void sort(List source, SortDefinition sortDefinition)
          Sort the given List according to the given sort definition.
static void sort(Object[] source, SortDefinition sortDefinition)
          Sort the given source according to the given sort definition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

logger

protected final Log logger
Constructor Detail

PropertyComparator

public PropertyComparator(SortDefinition sortDefinition)
Create a new PropertyComparator for the given SortDefinition.

See Also:
MutableSortDefinition

PropertyComparator

public PropertyComparator(String property,
                          boolean ignoreCase,
                          boolean ascending)
Create a PropertyComparator for the given settings.

Parameters:
property - the property to compare
ignoreCase - whether upper and lower case in String values should be ignored
ascending - whether to sort ascending (true) or descending (false)
Method Detail

getSortDefinition

public final SortDefinition getSortDefinition()
Return the SortDefinition that this comparator uses.


compare

public int compare(Object o1,
                   Object o2)
Specified by:
compare in interface Comparator

sort

public static void sort(List source,
                        SortDefinition sortDefinition)
                 throws BeansException
Sort the given List according to the given sort definition.

Note: Contained objects have to provide the given property in the form of a bean property, i.e. a getXXX method.

Parameters:
source - the input List
sortDefinition - the parameters to sort by
Throws:
IllegalArgumentException - in case of a missing propertyName
BeansException

sort

public static void sort(Object[] source,
                        SortDefinition sortDefinition)
                 throws BeansException
Sort the given source according to the given sort definition.

Note: Contained objects have to provide the given property in the form of a bean property, i.e. a getXXX method.

Parameters:
source - input source
sortDefinition - the parameters to sort by
Throws:
IllegalArgumentException - in case of a missing propertyName
BeansException

The Spring Framework

Copyright © 2002-2007 The Spring Framework.