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

COVERAGE SUMMARY FOR SOURCE FILE [GJYearOfEraDateTimeField.java]

nameclass, %method, %block, %line, %
GJYearOfEraDateTimeField.java100% (1/1)47%  (7/15)56%  (58/104)65%  (15/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GJYearOfEraDateTimeField100% (1/1)47%  (7/15)56%  (58/104)65%  (15/23)
add (long, long): long 0%   (0/1)0%   (0/6)0%   (0/1)
addWrapField (ReadablePartial, int, int [], int): int [] 0%   (0/1)0%   (0/8)0%   (0/1)
addWrapField (long, int): long 0%   (0/1)0%   (0/6)0%   (0/1)
getDifference (long, long): int 0%   (0/1)0%   (0/6)0%   (0/1)
getDifferenceAsLong (long, long): long 0%   (0/1)0%   (0/6)0%   (0/1)
readResolve (): Object 0%   (0/1)0%   (0/4)0%   (0/1)
remainder (long): long 0%   (0/1)0%   (0/5)0%   (0/1)
roundCeiling (long): long 0%   (0/1)0%   (0/5)0%   (0/1)
GJYearOfEraDateTimeField (DateTimeField, BasicChronology): void 100% (1/1)100% (8/8)100% (3/3)
add (long, int): long 100% (1/1)100% (6/6)100% (1/1)
get (long): int 100% (1/1)100% (13/13)100% (4/4)
getMaximumValue (): int 100% (1/1)100% (4/4)100% (1/1)
getMinimumValue (): int 100% (1/1)100% (2/2)100% (1/1)
roundFloor (long): long 100% (1/1)100% (5/5)100% (1/1)
set (long, int): long 100% (1/1)100% (20/20)100% (4/4)

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.DateTimeField;
19import org.joda.time.DateTimeFieldType;
20import org.joda.time.ReadablePartial;
21import org.joda.time.field.DecoratedDateTimeField;
22import org.joda.time.field.FieldUtils;
23 
24/**
25 * Provides time calculations for the year of era component of time.
26 * 
27 * @author Brian S O'Neill
28 * @since 1.0
29 */
30final class GJYearOfEraDateTimeField extends DecoratedDateTimeField {
31 
32    private static final long serialVersionUID = -5961050944769862059L;
33 
34    private final BasicChronology iChronology;
35 
36    /**
37     * Restricted constructor.
38     */
39    GJYearOfEraDateTimeField(DateTimeField yearField, BasicChronology chronology) {
40        super(yearField, DateTimeFieldType.yearOfEra());
41        iChronology = chronology;
42    }
43 
44    public int get(long instant) {
45        int year = getWrappedField().get(instant);
46        if (year <= 0) {
47            year = 1 - year;
48        }
49        return year;
50    }
51 
52    public long add(long instant, int years) {
53        return getWrappedField().add(instant, years);
54    }
55 
56    public long add(long instant, long years) {
57        return getWrappedField().add(instant, years);
58    }
59 
60    public long addWrapField(long instant, int years) {
61        return getWrappedField().addWrapField(instant, years);
62    }
63 
64    public int[] addWrapField(ReadablePartial instant, int fieldIndex, int[] values, int years) {
65        return getWrappedField().addWrapField(instant, fieldIndex, values, years);
66    }
67 
68    public int getDifference(long minuendInstant, long subtrahendInstant) {
69        return getWrappedField().getDifference(minuendInstant, subtrahendInstant);
70    }
71 
72    public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) {
73        return getWrappedField().getDifferenceAsLong(minuendInstant, subtrahendInstant);
74    }
75 
76    /**
77     * Set the year component of the specified time instant.
78     * 
79     * @param instant  the time instant in millis to update.
80     * @param year  the year (0,292278994) to update the time to.
81     * @return the updated time instant.
82     * @throws IllegalArgumentException  if year is invalid.
83     */
84    public long set(long instant, int year) {
85        FieldUtils.verifyValueBounds(this, year, 1, getMaximumValue());
86        if (iChronology.getYear(instant) <= 0) {
87            year = 1 - year;
88        }
89        return super.set(instant, year);
90    }
91 
92    public int getMinimumValue() {
93        return 1;
94    }
95 
96    public int getMaximumValue() {
97        return getWrappedField().getMaximumValue();
98    }
99 
100    public long roundFloor(long instant) {
101        return getWrappedField().roundFloor(instant);
102    }
103 
104    public long roundCeiling(long instant) {
105        return getWrappedField().roundCeiling(instant);
106    }
107 
108    public long remainder(long instant) {
109        return getWrappedField().remainder(instant);
110    }
111 
112    /**
113     * Serialization singleton
114     */
115    private Object readResolve() {
116        return iChronology.yearOfEra();
117    }
118}

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