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

COVERAGE SUMMARY FOR SOURCE FILE [BasicDayOfMonthDateTimeField.java]

nameclass, %method, %block, %line, %
BasicDayOfMonthDateTimeField.java100% (1/1)90%  (9/10)90%  (105/117)89%  (24/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BasicDayOfMonthDateTimeField100% (1/1)90%  (9/10)90%  (105/117)89%  (24/27)
readResolve (): Object 0%   (0/1)0%   (0/4)0%   (0/1)
getMaximumValue (ReadablePartial): int 100% (1/1)73%  (22/30)71%  (5/7)
BasicDayOfMonthDateTimeField (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% (4/4)100% (1/1)
getMaximumValue (ReadablePartial, int []): int 100% (1/1)100% (49/49)100% (10/10)
getMaximumValue (long): int 100% (1/1)100% (5/5)100% (1/1)
getMaximumValueForSet (long, int): int 100% (1/1)100% (6/6)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)

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.DateTimeFieldType;
19import org.joda.time.DurationField;
20import org.joda.time.ReadablePartial;
21import org.joda.time.field.PreciseDurationDateTimeField;
22 
23/**
24 * Provides time calculations for the day of the month component of time.
25 *
26 * @author Guy Allard
27 * @author Stephen Colebourne
28 * @author Brian S O'Neill
29 * @since 1.1, refactored from GJDayOfMonthDateTimeField
30 */
31final class BasicDayOfMonthDateTimeField extends PreciseDurationDateTimeField {
32 
33    private static final long serialVersionUID = -4677223814028011723L;
34 
35    private final BasicChronology iChronology;
36 
37    /**
38     * Restricted constructor.
39     */
40    BasicDayOfMonthDateTimeField(BasicChronology chronology, DurationField days) {
41        super(DateTimeFieldType.dayOfMonth(), days);
42        iChronology = chronology;
43    }
44 
45    //-----------------------------------------------------------------------
46    public int get(long instant) {
47        return iChronology.getDayOfMonth(instant);
48    }
49 
50    public DurationField getRangeDurationField() {
51        return iChronology.months();
52    }
53 
54    public int getMinimumValue() {
55        return 1;
56    }
57 
58    public int getMaximumValue() {
59        return iChronology.getDaysInMonthMax();
60    }
61 
62    public int getMaximumValue(long instant) {
63        return iChronology.getDaysInMonthMax(instant);
64    }
65 
66    public int getMaximumValue(ReadablePartial partial) {
67        if (partial.isSupported(DateTimeFieldType.monthOfYear())) {
68            int month = partial.get(DateTimeFieldType.monthOfYear());
69            if (partial.isSupported(DateTimeFieldType.year())) {
70                int year = partial.get(DateTimeFieldType.year());
71                return iChronology.getDaysInYearMonth(year, month);
72            }
73            return iChronology.getDaysInMonthMax(month);
74        }
75        return getMaximumValue();
76    }
77 
78    public int getMaximumValue(ReadablePartial partial, int[] values) {
79        int size = partial.size();
80        for (int i = 0; i < size; i++) {
81            if (partial.getFieldType(i) == DateTimeFieldType.monthOfYear()) {
82                int month = values[i];
83                for (int j = 0; j < size; j++) {
84                    if (partial.getFieldType(j) == DateTimeFieldType.year()) {
85                        int year = values[j];
86                        return iChronology.getDaysInYearMonth(year, month);
87                    }
88                }
89                return iChronology.getDaysInMonthMax(month);
90            }
91        }
92        return getMaximumValue();
93    }
94 
95    protected int getMaximumValueForSet(long instant, int value) {
96        return iChronology.getDaysInMonthMaxForSet(instant, value);
97    }
98 
99    /**
100     * Serialization singleton
101     */
102    private Object readResolve() {
103        return iChronology.dayOfMonth();
104    }
105}

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