ValueComparator.java
1.57 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
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.RepositoryException
* javax.jcr.Value
*/
package com.day.jcr.vault.util;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Comparator;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class ValueComparator
implements Comparator<Value> {
private static final ValueComparator INSTANCE = new ValueComparator();
private ValueComparator() {
}
public static ValueComparator getInstance() {
return INSTANCE;
}
@Override
public int compare(Value o1, Value o2) {
try {
switch (o1.getType()) {
case 2: {
throw new IllegalArgumentException("sorting of binary values not supported.");
}
case 5: {
return o1.getDate().compareTo(o2.getDate());
}
case 12: {
return o1.getDecimal().compareTo(o2.getDecimal());
}
case 4: {
return Double.valueOf(o1.getDouble()).compareTo(o2.getDouble());
}
case 3: {
return Long.valueOf(o1.getLong()).compareTo(o2.getLong());
}
}
return o1.getString().compareTo(o2.getString());
}
catch (RepositoryException e) {
throw new IllegalArgumentException((Throwable)e);
}
}
}