EMMA Coverage Report (generated Tue Oct 28 00:01:11 GMT 2008)
[all classes][org.joda.time.chrono]

COVERAGE SUMMARY FOR SOURCE FILE [BasicWeekOfWeekyearDateTimeField.java]

nameclass, %method, %block, %line, %
BasicWeekOfWeekyearDateTimeField.java100% (1/1)85%  (11/13)82%  (88/107)79%  (19/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BasicWeekOfWeekyearDateTimeField100% (1/1)85%  (11/13)82%  (88/107)79%  (19/24)
getMaximumValue (ReadablePartial): int 0%   (0/1)0%   (0/15)0%   (0/4)
readResolve (): Object 0%   (0/1)0%   (0/4)0%   (0/1)
BasicWeekOfWeekyearDateTimeField (BasicChronology, DurationField): void 100% (1/1)100% (8/8)100% (3/3)
get (long): int 100% (1/1)100% (5/5)100% (1/1)
getMaximumValue (): int 100% (1/1)100% (2/2)100% (1/1)
getMaximumValue (ReadablePartial, int []): int 100% (1/1)100% (26/26)100% (6/6)
getMaximumValue (long): int 100% (1/1)100% (10/10)100% (2/2)
getMaximumValueForSet (long, int): int 100% (1/1)100% (9/9)100% (1/1)
getMinimumValue (): int 100% (1/1)100% (2/2)100% (1/1)
getRangeDurationField (): DurationField 100% (1/1)100% (4/4)100% (1/1)
remainder (long): long 100% (1/1)100% (6/6)100% (1/1)
roundCeiling (long): long 100% (1/1)100% (8/8)100% (1/1)
roundFloor (long): long 100% (1/1)100% (8/8)100% (1/1)

1/*
2 *  Copyright 2001-2005 Stephen Colebourne
3 *
4 *  Licensed under the Apache License, Version 2.0 (the "License");
5 *  you may not use this file except in compliance with the License.
6 *  You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *  Unless required by applicable law or agreed to in writing, software
11 *  distributed under the License is distributed on an "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *  See the License for the specific language governing permissions and
14 *  limitations under the License.
15 */
16package org.joda.time.chrono;
17 
18import org.joda.time.DateTimeConstants;
19import org.joda.time.DateTimeFieldType;
20import org.joda.time.DurationField;
21import org.joda.time.ReadablePartial;
22import org.joda.time.field.PreciseDurationDateTimeField;
23 
24/**
25 * Provides time calculations for the week of a week based year component of time.
26 *
27 * @author Guy Allard
28 * @author Stephen Colebourne
29 * @author Brian S O'Neill
30 * @since 1.1, refactored from GJWeekOfWeekyearDateTimeField
31 */
32final class BasicWeekOfWeekyearDateTimeField extends PreciseDurationDateTimeField {
33 
34    private static final long serialVersionUID = -1587436826395135328L;
35 
36    private final BasicChronology iChronology;
37 
38    /**
39     * Restricted constructor
40     */
41    BasicWeekOfWeekyearDateTimeField(BasicChronology chronology, DurationField weeks) {
42        super(DateTimeFieldType.weekOfWeekyear(), weeks);
43        iChronology = chronology;
44    }
45 
46    /**
47     * Get the week of a week based year component of the specified time instant.
48     * 
49     * @see org.joda.time.DateTimeField#get(long)
50     * @param instant  the time instant in millis to query.
51     * @return the week of the year extracted from the input.
52     */
53    public int get(long instant) {
54        return iChronology.getWeekOfWeekyear(instant);
55    }
56 
57    public DurationField getRangeDurationField() {
58        return iChronology.weekyears();
59    }
60 
61    // 1970-01-01 is day of week 4, Thursday. The rounding methods need to
62    // apply a corrective alignment since weeks begin on day of week 1, Monday.
63 
64    public long roundFloor(long instant) {
65        return super.roundFloor(instant + 3 * DateTimeConstants.MILLIS_PER_DAY)
66            - 3 * DateTimeConstants.MILLIS_PER_DAY;
67    }
68 
69    public long roundCeiling(long instant) {
70        return super.roundCeiling(instant + 3 * DateTimeConstants.MILLIS_PER_DAY)
71            - 3 * DateTimeConstants.MILLIS_PER_DAY;
72    }
73 
74    public long remainder(long instant) {
75        return super.remainder(instant + 3 * DateTimeConstants.MILLIS_PER_DAY);
76    }
77 
78    public int getMinimumValue() {
79        return 1;
80    }
81 
82    public int getMaximumValue() {
83        return 53;
84    }
85 
86    public int getMaximumValue(long instant) {
87        int weekyear = iChronology.getWeekyear(instant);
88        return iChronology.getWeeksInYear(weekyear);
89    }
90 
91    public int getMaximumValue(ReadablePartial partial) {
92        if (partial.isSupported(DateTimeFieldType.weekyear())) {
93            int weekyear = partial.get(DateTimeFieldType.weekyear());
94            return iChronology.getWeeksInYear(weekyear);
95        }
96        return 53;
97    }
98 
99    public int getMaximumValue(ReadablePartial partial, int[] values) {
100        int size = partial.size();
101        for (int i = 0; i < size; i++) {
102            if (partial.getFieldType(i) == DateTimeFieldType.weekyear()) {
103                int weekyear = values[i];
104                return iChronology.getWeeksInYear(weekyear);
105            }
106        }
107        return 53;
108    }
109 
110    protected int getMaximumValueForSet(long instant, int value) {
111        return value > 52 ? getMaximumValue(instant) : 52;
112    }
113 
114    /**
115     * Serialization singleton
116     */
117    private Object readResolve() {
118        return iChronology.weekOfWeekyear();
119    }
120}

[all classes][org.joda.time.chrono]
EMMA 2.0.5312 (C) Vladimir Roubtsov