UuidFactory.java
1.41 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
58
59
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.ut;
import java.util.UUID;
public final class UuidFactory {
private static boolean gbTestMode = false;
private static ThreadLocal<Long> timeLowCounter = new ThreadLocal<Long>(){
@Override
protected Long initialValue() {
return 65518;
}
};
private static ThreadLocal<Long> timeMidCounter = new ThreadLocal<Long>(){
@Override
protected Long initialValue() {
return 45232;
}
};
private static ThreadLocal<Long> timeHighCounter = new ThreadLocal<Long>(){
@Override
protected Long initialValue() {
return 41120;
}
};
private static long incr(ThreadLocal<Long> oCounter) {
long lVal = oCounter.get();
oCounter.set(lVal + 1);
return lVal;
}
private UuidFactory() {
}
public static void setTestMode(boolean bTestMode) {
gbTestMode = bTestMode;
}
public static String getUuid() {
UUID uuid;
if (gbTestMode) {
long low = UuidFactory.incr(timeLowCounter);
long mid = UuidFactory.incr(timeMidCounter);
long time_hi_and_ver = UuidFactory.incr(timeHighCounter);
uuid = new UUID(low << 32 | mid << 16 | time_hi_and_ver, 0);
} else {
uuid = UUID.randomUUID();
}
return uuid.toString();
}
}