StopWatch.java
3.38 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package org.apache.commons.lang3.time;
import java.util.concurrent.TimeUnit;
public class StopWatch
{
private b a = b.a;
private int b = a.b;
private long c;
private long d;
private long e;
public static StopWatch createStarted()
{
StopWatch localStopWatch = new StopWatch();
localStopWatch.start();
return localStopWatch;
}
public long getNanoTime()
{
if ((this.a == b.c) || (this.a == b.d)) {
return this.e - this.c;
}
if (this.a == b.a) {
return 0L;
}
if (this.a == b.b) {
return System.nanoTime() - this.c;
}
throw new RuntimeException("Illegal running state has occurred.");
}
public long getSplitNanoTime()
{
if (this.b != a.a) {
throw new IllegalStateException("Stopwatch must be split to get the split time. ");
}
return this.e - this.c;
}
public long getSplitTime()
{
return getSplitNanoTime() / 1000000L;
}
public long getStartTime()
{
if (this.a == b.a) {
throw new IllegalStateException("Stopwatch has not been started");
}
return this.d;
}
public long getTime()
{
return getNanoTime() / 1000000L;
}
public long getTime(TimeUnit paramTimeUnit)
{
return paramTimeUnit.convert(getNanoTime(), TimeUnit.NANOSECONDS);
}
public boolean isStarted()
{
return this.a.a();
}
public boolean isStopped()
{
return this.a.b();
}
public boolean isSuspended()
{
return this.a.c();
}
public void reset()
{
this.a = b.a;
this.b = a.b;
}
public void resume()
{
if (this.a != b.d) {
throw new IllegalStateException("Stopwatch must be suspended to resume. ");
}
this.c += System.nanoTime() - this.e;
this.a = b.b;
}
public void split()
{
if (this.a != b.b) {
throw new IllegalStateException("Stopwatch is not running. ");
}
this.e = System.nanoTime();
this.b = a.a;
}
public void start()
{
if (this.a == b.c) {
throw new IllegalStateException("Stopwatch must be reset before being restarted. ");
}
if (this.a != b.a) {
throw new IllegalStateException("Stopwatch already started. ");
}
this.c = System.nanoTime();
this.d = System.currentTimeMillis();
this.a = b.b;
}
public void stop()
{
if ((this.a != b.b) && (this.a != b.d)) {
throw new IllegalStateException("Stopwatch is not running. ");
}
if (this.a == b.b) {
this.e = System.nanoTime();
}
this.a = b.c;
}
public void suspend()
{
if (this.a != b.b) {
throw new IllegalStateException("Stopwatch must be running to suspend. ");
}
this.e = System.nanoTime();
this.a = b.d;
}
public String toSplitString()
{
return DurationFormatUtils.formatDurationHMS(getSplitTime());
}
public String toString()
{
return DurationFormatUtils.formatDurationHMS(getTime());
}
public void unsplit()
{
if (this.b != a.a) {
throw new IllegalStateException("Stopwatch has not been split. ");
}
this.b = a.b;
}
static enum a {}
static abstract enum b
{
private b() {}
abstract boolean a();
abstract boolean b();
abstract boolean c();
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/org/apache/commons/lang3/time/StopWatch.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/