Package muntjac :: Package data :: Package util :: Module item_sorter
[hide private]
[frames] | no frames]

Source Code for Module muntjac.data.util.item_sorter

 1  # Copyright (C) 2012 Vaadin Ltd.  
 2  # Copyright (C) 2012 Richard Lincoln 
 3  #  
 4  # Licensed under the Apache License, Version 2.0 (the "License");  
 5  # you may not use this file except in compliance with the License.  
 6  # You may obtain a copy of the License at  
 7  #  
 8  #     http://www.apache.org/licenses/LICENSE-2.0  
 9  #  
10  # Unless required by applicable law or agreed to in writing, software  
11  # distributed under the License is distributed on an "AS IS" BASIS,  
12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
13  # See the License for the specific language governing permissions and  
14  # limitations under the License. 
15   
16  """An item comparator which is compatible with the ISortable interface.""" 
17   
18   
19 -class IItemSorter(object): # FIXME: Comparator, Cloneable, Serializable
20 """An item comparator which is compatible with the L{ISortable} interface. 21 The C{IItemSorter} interface can be used in C{Sortable} implementations 22 to provide a custom sorting method. 23 """ 24
25 - def setSortProperties(self, container, propertyId, ascending):
26 """Sets the parameters for an upcoming sort operation. The parameters 27 determine what container to sort and how the C{IItemSorter} sorts the 28 container. 29 30 @param container: 31 The container that will be sorted. The container must 32 contain the propertyIds given in the C{propertyId} 33 parameter. 34 @param propertyId: 35 The property ids used for sorting. The property ids must 36 exist in the container and should only be used if they are 37 also sortable, i.e include in the collection returned by 38 C{container.getSortableContainerPropertyIds()}. See 39 L{ISortable.sort} for more information. 40 @param ascending: 41 Sorting order flags for each property id. See 42 L{ISortable.sort} for more information. 43 """ 44 raise NotImplementedError
45 46
47 - def compare(self, itemId1, itemId2):
48 """Compares its two arguments for order. Returns a negative integer, 49 zero, or a positive integer as the first argument is less than, equal 50 to, or greater than the second. 51 52 The parameters for the C{IItemSorter} C{compare()} method must always 53 be item ids which exist in the container set using L{setSortProperties}. 54 55 @see: L{IComparator.compare} 56 """ 57 raise NotImplementedError
58