View Javadoc

1   /*
2    * @(#) Sortable.java April 15, 2004 Copyright (c) 2002-2005-2004 Delft
3    * University of Technology Jaffalaan 5, 2628 BX Delft, the Netherlands. All
4    * rights reserved. This software is proprietary information of Delft University
5    * of Technology The code is published under the Lesser General Public License
6    */
7   package nl.tudelft.simulation.introspection.sortable;
8   
9   /***
10   * Defines methods to define, retrieve and perform sorting definitions.
11   * <p>
12   * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
13   * University of Technology </a>, the Netherlands. <br>
14   * See for project information <a
15   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
16   * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
17   * General Public License (LGPL) </a>, no warranty.
18   * 
19   * @author <a href="http://www.peter-jacobs.com/index.htm">Peter Jacobs </a>
20   * @version 1.2 Apr 14, 2004
21   * @since 1.5
22   */
23  public interface Sortable
24  {
25      /***
26       * Defines the sort definition
27       */
28      public static interface Definition
29      {
30          /***
31           * @return Returns the field to which this sorting definition applies
32           */
33          int getFieldID();
34  
35          /***
36           * Returns whether this definition defines an ascending sort.
37           * 
38           * @return A 'false' return value implies a descending sort definition.
39           */
40          boolean isAcendingSort();
41  
42          /***
43           * Allows dynamic definitions
44           * 
45           * @param ascending whether the sort is ascending
46           */
47          void setAscending(boolean ascending);
48      }
49  
50      /***
51       * @return Returns the current definitions defined for this Sortable. The
52       *         sequence of the definitions matches the sorting sequence, in that
53       *         a definition will be performed before another definition if
54       *         having a lower index.
55       */
56      Definition[] getDefinitions();
57  
58      /***
59       * Sets the current definitions defined for this Sortable. The sequence of
60       * the definitions matches the sorting sequence, in that a definition will
61       * be performed before another definition if having a lower index.
62       * 
63       * @param definitions An array of sort definitions. If multiple definitions
64       *        for the same field are included, the one with highest index will
65       *        be applied.
66       */
67      void setDefinitions(Definition[] definitions);
68  
69      /***
70       * Instructs this Sortable to sort based on currently set sorting
71       * definitions.
72       */
73      void sort();
74  }