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

COVERAGE SUMMARY FOR SOURCE FILE [BasicDayOfYearDateTimeField.java]

nameclass, %method, %block, %line, %
BasicDayOfYearDateTimeField.java100% (1/1)80%  (8/10)79%  (79/100)77%  (17/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BasicDayOfYearDateTimeField100% (1/1)80%  (8/10)79%  (79/100)77%  (17/22)
getMaximumValue (ReadablePartial): int 0%   (0/1)0%   (0/17)0%   (0/4)
readResolve (): Object 0%   (0/1)0%   (0/4)0%   (0/1)
BasicDayOfYearDateTimeField (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% (28/28)100% (6/6)
getMaximumValue (long): int 100% (1/1)100% (10/10)100% (2/2)
getMaximumValueForSet (long, int): int 100% (1/1)100% (18/18)100% (2/2)
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 year component of time.
25 *
26 * @author Guy Allard
27 * @author Stephen Colebourne
28 * @author Brian S O'Neill
29 * @since 1.1, refactored from GJDayOfYearDateTimeField
30 */
31final class BasicDayOfYearDateTimeField extends PreciseDurationDateTimeField {
32 
33    private static final long serialVersionUID = -6821236822336841037L;
34 
35    private final BasicChronology iChronology;
36 
37    /**
38     * Restricted constructor
39     */
40    BasicDayOfYearDateTimeField(BasicChronology chronology, DurationField days) {
41        super(DateTimeFieldType.dayOfYear(), days);
42        iChronology = chronology;
43    }
44 
45    /**
46     * Get the day of the year component of the specified time instant.
47     * 
48     * @param instant  the time instant in millis to query.
49     * @return the day of the year extracted from the input.
50     */
51    public int get(long instant) {
52        return iChronology.getDayOfYear(instant);
53    }
54 
55    public DurationField getRangeDurationField() {
56        return iChronology.years();
57    }
58 
59    public int getMinimumValue() {
60        return 1;
61    }
62 
63    public int getMaximumValue() {
64        return iChronology.getDaysInYearMax();
65    }
66 
67    public int getMaximumValue(long instant) {
68        int year = iChronology.getYear(instant);
69        return iChronology.getDaysInYear(year);
70    }
71 
72    public int getMaximumValue(ReadablePartial partial) {
73        if (partial.isSupported(DateTimeFieldType.year())) {
74            int year = partial.get(DateTimeFieldType.year());
75            return iChronology.getDaysInYear(year);
76        }
77        return iChronology.getDaysInYearMax();
78    }
79 
80    public int getMaximumValue(ReadablePartial partial, int[] values) {
81        int size = partial.size();
82        for (int i = 0; i < size; i++) {
83            if (partial.getFieldType(i) == DateTimeFieldType.year()) {
84                int year = values[i];
85                return iChronology.getDaysInYear(year);
86            }
87        }
88        return iChronology.getDaysInYearMax();
89    }
90 
91    protected int getMaximumValueForSet(long instant, int value) {
92        int maxLessOne = iChronology.getDaysInYearMax() - 1;
93        return (value > maxLessOne || value < 1) ? getMaximumValue(instant) : maxLessOne;
94    }
95 
96    /**
97     * Serialization singleton
98     */
99    private Object readResolve() {
100        return iChronology.dayOfYear();
101    }
102}

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