KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > web > ui > common > SortableSelectItem


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.web.ui.common;
18
19 import javax.faces.model.SelectItem;
20
21 /**
22  * Wrapper class to facilitate case-insensitive sorting functionality against our SelectItem objects
23  *
24  * @author Kevin Roast
25  */

26 public final class SortableSelectItem extends SelectItem implements Comparable JavaDoc
27 {
28    public SortableSelectItem(String JavaDoc value, String JavaDoc label, String JavaDoc sort)
29    {
30       super(value, label);
31       this.sort = sort;
32    }
33    
34    public int compareTo(Object JavaDoc obj2)
35    {
36       if (this.sort == null && obj2 == null) return 0;
37       if (this.sort == null) return -1;
38       if (obj2 == null) return 1;
39       return this.sort.compareToIgnoreCase( ((SortableSelectItem)obj2).sort );
40    }
41    
42    private String JavaDoc sort;
43 }
44
Popular Tags