BaseSingleFieldPeriod.java
5.68 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
174
175
176
177
178
179
180
181
182
183
184
185
package org.joda.time.base;
import java.io.Serializable;
import org.joda.time.Chronology;
import org.joda.time.DateTimeUtils;
import org.joda.time.DurationField;
import org.joda.time.DurationFieldType;
import org.joda.time.MutablePeriod;
import org.joda.time.Period;
import org.joda.time.PeriodType;
import org.joda.time.ReadableInstant;
import org.joda.time.ReadablePartial;
import org.joda.time.ReadablePeriod;
import org.joda.time.chrono.ISOChronology;
import org.joda.time.field.FieldUtils;
public abstract class BaseSingleFieldPeriod
implements Serializable, Comparable<BaseSingleFieldPeriod>, ReadablePeriod
{
private static final long serialVersionUID = 9386874258972L;
private volatile int a;
protected BaseSingleFieldPeriod(int paramInt)
{
this.a = paramInt;
}
protected static int between(ReadableInstant paramReadableInstant1, ReadableInstant paramReadableInstant2, DurationFieldType paramDurationFieldType)
{
if ((paramReadableInstant1 == null) || (paramReadableInstant2 == null)) {
throw new IllegalArgumentException("ReadableInstant objects must not be null");
}
return paramDurationFieldType.getField(DateTimeUtils.getInstantChronology(paramReadableInstant1)).getDifference(paramReadableInstant2.getMillis(), paramReadableInstant1.getMillis());
}
protected static int between(ReadablePartial paramReadablePartial1, ReadablePartial paramReadablePartial2, ReadablePeriod paramReadablePeriod)
{
if ((paramReadablePartial1 == null) || (paramReadablePartial2 == null)) {
throw new IllegalArgumentException("ReadablePartial objects must not be null");
}
if (paramReadablePartial1.size() != paramReadablePartial2.size()) {
throw new IllegalArgumentException("ReadablePartial objects must have the same set of fields");
}
int j = paramReadablePartial1.size();
int i = 0;
while (i < j)
{
if (paramReadablePartial1.getFieldType(i) != paramReadablePartial2.getFieldType(i)) {
throw new IllegalArgumentException("ReadablePartial objects must have the same set of fields");
}
i += 1;
}
if (!DateTimeUtils.isContiguous(paramReadablePartial1)) {
throw new IllegalArgumentException("ReadablePartial objects must be contiguous");
}
Chronology localChronology = DateTimeUtils.getChronology(paramReadablePartial1.getChronology()).withUTC();
return localChronology.get(paramReadablePeriod, localChronology.set(paramReadablePartial1, 0L), localChronology.set(paramReadablePartial2, 0L))[0];
}
protected static int standardPeriodIn(ReadablePeriod paramReadablePeriod, long paramLong)
{
int i = 0;
if (paramReadablePeriod == null) {
return 0;
}
ISOChronology localISOChronology = ISOChronology.getInstanceUTC();
long l2;
for (long l1 = 0L; i < paramReadablePeriod.size(); l1 = l2)
{
int j = paramReadablePeriod.getValue(i);
l2 = l1;
if (j != 0)
{
DurationField localDurationField = paramReadablePeriod.getFieldType(i).getField(localISOChronology);
if (!localDurationField.isPrecise()) {
throw new IllegalArgumentException("Cannot convert period to duration as " + localDurationField.getName() + " is not precise in the period " + paramReadablePeriod);
}
l2 = FieldUtils.safeAdd(l1, FieldUtils.safeMultiply(localDurationField.getUnitMillis(), j));
}
i += 1;
}
return FieldUtils.safeToInt(l1 / paramLong);
}
public int compareTo(BaseSingleFieldPeriod paramBaseSingleFieldPeriod)
{
if (paramBaseSingleFieldPeriod.getClass() != getClass()) {
throw new ClassCastException(getClass() + " cannot be compared to " + paramBaseSingleFieldPeriod.getClass());
}
int i = paramBaseSingleFieldPeriod.getValue();
int j = getValue();
if (j > i) {
return 1;
}
if (j < i) {
return -1;
}
return 0;
}
public boolean equals(Object paramObject)
{
if (this == paramObject) {}
do
{
return true;
if (!(paramObject instanceof ReadablePeriod)) {
return false;
}
paramObject = (ReadablePeriod)paramObject;
} while ((((ReadablePeriod)paramObject).getPeriodType() == getPeriodType()) && (((ReadablePeriod)paramObject).getValue(0) == getValue()));
return false;
}
public int get(DurationFieldType paramDurationFieldType)
{
if (paramDurationFieldType == getFieldType()) {
return getValue();
}
return 0;
}
public abstract DurationFieldType getFieldType();
public DurationFieldType getFieldType(int paramInt)
{
if (paramInt != 0) {
throw new IndexOutOfBoundsException(String.valueOf(paramInt));
}
return getFieldType();
}
public abstract PeriodType getPeriodType();
protected int getValue()
{
return this.a;
}
public int getValue(int paramInt)
{
if (paramInt != 0) {
throw new IndexOutOfBoundsException(String.valueOf(paramInt));
}
return getValue();
}
public int hashCode()
{
return (getValue() + 459) * 27 + getFieldType().hashCode();
}
public boolean isSupported(DurationFieldType paramDurationFieldType)
{
return paramDurationFieldType == getFieldType();
}
protected void setValue(int paramInt)
{
this.a = paramInt;
}
public int size()
{
return 1;
}
public MutablePeriod toMutablePeriod()
{
MutablePeriod localMutablePeriod = new MutablePeriod();
localMutablePeriod.add(this);
return localMutablePeriod;
}
public Period toPeriod()
{
return Period.ZERO.withFields(this);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/org/joda/time/base/BaseSingleFieldPeriod.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/