Oracle

com.compoze.collab
Class ItemComparator

java.lang.Object
  extended by com.compoze.collab.ItemComparator
All Implemented Interfaces:
java.util.Comparator

public class ItemComparator
extends java.lang.Object
implements java.util.Comparator

Comparator for arbitrary properties on items. Items are compared by one or more property values. The following sort criteria is used for each of the different property value types:

Value Type Sort Criteria
Key.VALUE_STRING Collator
Key.VALUE_SHORT Comparable
Key.VALUE_INTEGER Comparable
Key.VALUE_LONG Comparable
Key.VALUE_BOOLEAN false < true
Key.VALUE_FLOAT Comparable
Key.VALUE_DOUBLE Comparable
Key.VALUE_BINARY IllegalArgumentException
Key.VALUE_DATE Comparable
Key.VALUE_ITEM IllegalArgumentException
Key.VALUE_ENUMELEMENT Comparable
Key.VALUE_UNKNOWN Comparable or IllegalArgumentException if unknown objects do not implement Comparable
Key.VALUE_SERIALIZABLE Comparable or IllegalArgumentException if serialized objects do not implement Comparable


Constructor Summary
ItemComparator(SortProperty[] sortProps)
          Constructor (default Collator).
ItemComparator(SortProperty[] sortProps, java.text.Collator collator)
          Constructor.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
           
 boolean equals(java.lang.Object obj)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItemComparator

public ItemComparator(SortProperty[] sortProps)
Constructor (default Collator).

Parameters:
sortProps - the sort properties (not null). Properties earlier in the array have higher sort priority.

ItemComparator

public ItemComparator(SortProperty[] sortProps,
                      java.text.Collator collator)
Constructor.

Parameters:
sortProps - the sort properties (not null). Properties earlier in the array have higher sort priority.
collator - the collator for comparing String values (null for default Collator)
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Specified by:
compare in interface java.util.Comparator
See Also:
(Object, Object)

equals

public boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

Oracle

Copyright ©1999-2008 Oracle All rights reserved.