2
* AccessODF - Accessibility checker for OpenOffice.org and LibreOffice Writer.
4
* Copyright (c) 2011 by DocArch <http://www.docarch.be>.
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as
8
* published by the Free Software Foundation, either version 3 of the
9
* License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
package be.docarch.accessodf;
22
import java.util.ArrayList;
23
import java.util.TreeMap;
29
public class FilterSorter implements java.util.Comparator<Issue> {
31
public static enum Property { NATURAL, CATEGORY, CHECKID, NAME }
32
public static final Property NATURAL = Property.NATURAL;
33
public static final Property CHECKID = Property.CHECKID;
34
public static final Property NAME = Property.NAME;
36
private TreeMap<Property, Boolean> upDown;
37
private ArrayList<Property> priority;
40
public FilterSorter() {
42
upDown = new TreeMap<Property, Boolean>();
43
upDown.put(NATURAL, true);
44
upDown.put(NAME, true);
45
upDown.put(CHECKID, true);
46
priority = new ArrayList<Property>();
47
priority.add(NATURAL);
49
priority.add(CHECKID);
53
public void setOrder(Property property,
56
if (this.upDown.containsKey(property)) {
57
this.upDown.put(property, upDown);
61
public void setOrderPriority(Property property,
62
boolean highestLowest) {
64
if (priority.contains(property)) {
65
priority.remove(property);
67
priority.add(0, property);
69
priority.add(property);
74
public int compare(Issue entry1,
77
if (entry1 == null && entry2 == null) {
79
} else if (entry1 == null) {
81
} else if (entry2 == null) {
88
for (int i=0; i<priority.size(); i++) {
89
property = priority.get(i);
92
compare = (entry1.getName().compareTo(entry2.getName()));
95
compare = (entry1.getCheck().getIdentifier().compareTo(entry2.getCheck().getIdentifier()));
102
if (upDown.get(property)) {
113
public boolean accept(Issue entry) {
114
return (entry != null);