Dateiverwaltung für die WebBox
ulrich
2018-03-03 eb2a2d78152c7ca689e3aac116c107229a896a66
commit | author | age
d14d78 1 /*
U 2     Dateiverwaltung - File management in your browser
3     Copyright (C) 2017 Ulrich Hilger, http://uhilger.de
4
5     This program is free software: you can redistribute it and/or modify
6     it under the terms of the GNU Affero General Public License as
7     published by the Free Software Foundation, either version 3 of the
8     License, or (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU Affero General Public License for more details.
14
15     You should have received a copy of the GNU Affero General Public License
16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 package de.uhilger.filecms.pub;
20
21 import java.io.File;
22
23 /**
24  *
25  * @author ulrich
26  */
27 public class FileNameComparator extends AbstractComparator {
28   
29   public FileNameComparator(String order) {
30     this.order = order;
31   }
32   
33   @Override
34   public int compare(Object o1, Object o2) {
35     File f1 = null;
36     File f2 = null;
37     if(o1 instanceof File) {
38       f1 = (File) o1;
39     }
40     if(o2 instanceof File) {
41       f2 = (File) o2;
42     }
43     if(f1 != null && f2 != null) {
44       if(order != null && order.equalsIgnoreCase(ORDER_ASC)) {
45         return f1.getName().compareToIgnoreCase(f2.getName());
46       } else {
47         return f2.getName().compareToIgnoreCase(f1.getName());
48       }
49     } else {
50       logger.fine("f1 oder f2 null");
51       return 0;      
52     }
53   }
54 }