View Javadoc

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