net.sf.fikin.pojostate.state
Class StateSorter

java.lang.Object
  extended by net.sf.fikin.pojostate.state.StateSorter
All Implemented Interfaces:
java.util.Comparator

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

Implements sorting algorithms for Property objects

It supports sorting based on name, description and value. It supports ascending or descending ordering. created on Mar 6, 2007

Since:
Version:
$Revision: 1.1 $
Author:
fiykov

Field Summary
protected  int leadField
          leading State field
protected  int order
          field's order
 
Constructor Summary
StateSorter(int leadField, int order)
          Initialize the comparator with given leading field and order
 
Method Summary
 int compare(java.lang.Object arg0, java.lang.Object arg1)
          actual comparator logic based on what this object has been initialized with If leading field is getValue() and in case of getting DecorationException upon executing it, it will perform comparison based on getName() ASC.
 
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

leadField

protected int leadField
leading State field


order

protected int order
field's order

Constructor Detail

StateSorter

public StateSorter(int leadField,
                   int order)
Initialize the comparator with given leading field and order

Parameters:
leadField - is the leading property
order - is ascending or descending
Method Detail

compare

public int compare(java.lang.Object arg0,
                   java.lang.Object arg1)
actual comparator logic based on what this object has been initialized with

If leading field is getValue() and in case of getting DecorationException upon executing it, it will perform comparison based on getName() ASC.

If leading field is getValue() or getDescription() and comparison finds them equal, it is returned the result of getName() with appropriate ordering. This is pretty much as an acting second field for ordering.

Specified by:
compare in interface java.util.Comparator
Parameters:
arg0 -
arg1 -
Returns:
1, -1 or 0


Copyright © 2005 Nikolay Fiykov. All Rights Reserved.