001 /*
002 * Copyright 2001-2005 Stephen Colebourne
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.joda.time.convert;
017
018 import org.joda.time.Chronology;
019 import org.joda.time.PeriodType;
020 import org.joda.time.ReadWritablePeriod;
021
022 /**
023 * PeriodConverter defines how an object is converted to a time period.
024 *
025 * @author Stephen Colebourne
026 * @author Brian S O'Neill
027 * @since 1.0
028 */
029 public interface PeriodConverter extends Converter {
030
031 /**
032 * Extracts duration values from an object of this converter's type, and
033 * sets them into the given ReadWritableDuration.
034 *
035 * @param period the period to modify
036 * @param object the object to convert, must not be null
037 * @param chrono the chronology to use, must not be null
038 * @throws ClassCastException if the object is invalid
039 */
040 void setInto(ReadWritablePeriod period, Object object, Chronology chrono);
041
042 /**
043 * Selects a suitable period type for the given object.
044 *
045 * @param object the object to examine, must not be null
046 * @return the period type, never null
047 * @throws ClassCastException if the object is invalid
048 */
049 PeriodType getPeriodType(Object object);
050
051 }