org.openswing.swing.table.client
Class OrderPolicy

java.lang.Object
  extended byorg.openswing.swing.table.client.OrderPolicy

public class OrderPolicy
extends java.lang.Object

Title: OpenSwing Framework

Description: Class used by grid control in order to sort columns in a custom way. Default column sort algorithm can be changed by overriding compareAttributeValues method.

Copyright: Copyright (C) 2006 Mauro Carniel

This file is part of OpenSwing Framework. This library is free software; you can redistribute it and/or modify it under the terms of the (LGPL) Lesser General Public License as published by the Free Software Foundation; GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be contacted at: maurocarniel@tin.it


Constructor Summary
OrderPolicy()
           
 
Method Summary
 void afterSorting(VOListTableModel model)
          Callback method invoked by grid after internally sorting columns.
 int compareAttributeValues(java.lang.String attributeName, java.lang.String sortVersus, java.lang.Object val1, java.lang.Object val2, VOListTableModel model)
          Callback method invoked by grid in order to sort the specified column: it can be overrided in order to define a custom sorting algorithm.
 int compareRow(VOListAdapter modelAdapter, Grids grids, VOListTableModel model, ValueObject o1, ValueObject o2)
          Method invoked by Grid component in order to compare two rows of the same VOListModel.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderPolicy

public OrderPolicy()
Method Detail

compareRow

public final int compareRow(VOListAdapter modelAdapter,
                            Grids grids,
                            VOListTableModel model,
                            ValueObject o1,
                            ValueObject o2)
Method invoked by Grid component in order to compare two rows of the same VOListModel.

Parameters:
modelAdapter - TableModel adapter, used to link ValueObjects to TableModel
grids - Grids grid component
model - grid model
o1 - value object related to first row
o2 - value object related to second row
Returns:
row comparison result

compareAttributeValues

public int compareAttributeValues(java.lang.String attributeName,
                                  java.lang.String sortVersus,
                                  java.lang.Object val1,
                                  java.lang.Object val2,
                                  VOListTableModel model)
Callback method invoked by grid in order to sort the specified column: it can be overrided in order to define a custom sorting algorithm. The default implementation is able to compare Date, Number and String objects.

Parameters:
attributeName - attribute name that identities the column to sort
sortVersus - sorting order; allowed values: Consts.ASC_SORTED,Consts.DESC_SORTED,Consts.NO_SORTED
val1 - first value to compare
val2 - second value to compare
model - VOListModel grid model to sort
Returns:
cell values comparison result: -1 if val1 is less than val2, +1 if val1 is greater than val2, 0 if val1 is equals to val2

afterSorting

public void afterSorting(VOListTableModel model)
Callback method invoked by grid after internally sorting columns.

Parameters:
model - VOListModel grid model just sorted