NodeNameComparator.java
1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* javax.jcr.RepositoryException
*/
package com.day.jcr.vault.util;
import java.util.Comparator;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class NodeNameComparator
implements Comparator<Node> {
public static final NodeNameComparator INSTANCE = new NodeNameComparator();
@Override
public int compare(Node o1, Node o2) {
try {
String n1 = o1.getName().toLowerCase();
String n2 = o2.getName().toLowerCase();
int i1 = n1.indexOf(58);
int i2 = n2.indexOf(58);
if (i1 >= 0 && i2 < 0) {
return -1;
}
if (i1 < 0 && i2 >= 0) {
return 1;
}
if (n1.equals(n2)) {
return o1.getIndex() - o2.getIndex();
}
return n1.compareTo(n2);
}
catch (RepositoryException e) {
throw new IllegalStateException((Throwable)e);
}
}
}