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

COVERAGE SUMMARY FOR SOURCE FILE [ReadablePeriodConverter.java]

nameclass, %method, %block, %line, %
ReadablePeriodConverter.java100% (1/1)100% (5/5)100% (28/28)100% (8/8)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ReadablePeriodConverter100% (1/1)100% (5/5)100% (28/28)100% (8/8)
<static initializer> 100% (1/1)100% (5/5)100% (1/1)
ReadablePeriodConverter (): void 100% (1/1)100% (3/3)100% (2/2)
getPeriodType (Object): PeriodType 100% (1/1)100% (6/6)100% (2/2)
getSupportedType (): Class 100% (1/1)100% (9/9)100% (1/1)
setInto (ReadWritablePeriod, Object, Chronology): void 100% (1/1)100% (5/5)100% (2/2)

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.convert;
17 
18import org.joda.time.Chronology;
19import org.joda.time.PeriodType;
20import org.joda.time.ReadWritablePeriod;
21import org.joda.time.ReadablePeriod;
22 
23/**
24 * ReadablePeriodConverter extracts milliseconds and chronology from a ReadablePeriod.
25 *
26 * @author Stephen Colebourne
27 * @author Brian S O'Neill
28 * @since 1.0
29 */
30class ReadablePeriodConverter extends AbstractConverter
31        implements PeriodConverter {
32 
33    /**
34     * Singleton instance.
35     */
36    static final ReadablePeriodConverter INSTANCE = new ReadablePeriodConverter();
37 
38    /**
39     * Restricted constructor.
40     */
41    protected ReadablePeriodConverter() {
42        super();
43    }
44 
45    //-----------------------------------------------------------------------
46    /**
47     * Extracts duration values from an object of this converter's type, and
48     * sets them into the given ReadWritablePeriod.
49     *
50     * @param duration duration to get modified
51     * @param object  the object to convert, must not be null
52     * @param chrono  the chronology to use
53     * @throws NullPointerException if the duration or object is null
54     * @throws ClassCastException if the object is an invalid type
55     * @throws IllegalArgumentException if the object is invalid
56     */
57    public void setInto(ReadWritablePeriod duration, Object object, Chronology chrono) {
58        duration.setPeriod((ReadablePeriod) object);
59    }
60 
61    /**
62     * Selects a suitable period type for the given object.
63     *
64     * @param object  the object to examine, must not be null
65     * @return the period type from the readable duration
66     * @throws NullPointerException if the object is null
67     * @throws ClassCastException if the object is an invalid type
68     */
69    public PeriodType getPeriodType(Object object) {
70        ReadablePeriod period = (ReadablePeriod) object;
71        return period.getPeriodType();
72    }
73 
74    //-----------------------------------------------------------------------
75    /**
76     * Returns ReadablePeriod class.
77     * 
78     * @return ReadablePeriod.class
79     */
80    public Class getSupportedType() {
81        return ReadablePeriod.class;
82    }
83 
84}

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