KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > SortCriteria


1 /*
2   Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com>
3   
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

17
18 package org.objectweb.jac.aspects.gui;
19
20 public class SortCriteria {
21     int column;
22     boolean ascending;
23     public SortCriteria(int column, boolean ascending) {
24         this.column = column;
25         this.ascending = ascending;
26     }
27     public int getColumn() {
28         return column;
29     }
30     public boolean isAscending() {
31         return ascending;
32     }
33     public void toggleAscending() {
34         ascending = !ascending;
35     }
36
37     public String JavaDoc toString() {
38         return (ascending?"":"-")+column;
39     }
40
41     public boolean equals(Object JavaDoc o) {
42         if (!(o instanceof SortCriteria))
43             return false;
44         SortCriteria criteria = (SortCriteria)o;
45         return criteria.column==column && criteria.ascending==ascending;
46     }
47
48     public int hashCode() {
49         return column ^ (ascending ? 0 : 2^31);
50     }
51 }
52
Popular Tags