|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.joda.time.base.BaseSingleFieldPeriod
BaseSingleFieldPeriod is an abstract implementation of ReadablePeriod that manages a single duration field, such as days or minutes.
This class should generally not be used directly by API users.
The ReadablePeriod
interface should be used when different
kinds of period objects are to be referenced.
BaseSingleFieldPeriod subclasses may be mutable and not thread-safe.
Method Summary | |
int |
compareTo(Object other)
Compares this period to another object of the same class. |
boolean |
equals(Object period)
Compares this object with the specified object for equality based on the value of each field. |
int |
get(DurationFieldType type)
Gets the value of a duration field represented by this period. |
abstract DurationFieldType |
getFieldType()
Gets the single duration field type. |
DurationFieldType |
getFieldType(int index)
Gets the field type at the specified index. |
abstract PeriodType |
getPeriodType()
Gets the period type which matches the duration field type. |
int |
getValue(int index)
Gets the value at the specified index. |
int |
hashCode()
Gets a hash code for the period as defined by ReadablePeriod. |
boolean |
isSupported(DurationFieldType type)
Checks whether the duration field specified is supported by this period. |
int |
size()
Gets the number of fields that this period supports, which is one. |
MutablePeriod |
toMutablePeriod()
Get this object as a MutablePeriod . |
Period |
toPeriod()
Get this period as an immutable Period object. |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.joda.time.ReadablePeriod |
toString |
Method Detail |
public abstract DurationFieldType getFieldType()
public abstract PeriodType getPeriodType()
getPeriodType
in interface ReadablePeriod
public int size()
size
in interface ReadablePeriod
public DurationFieldType getFieldType(int index)
The only index supported by this period is zero which returns the field type of this class.
getFieldType
in interface ReadablePeriod
index
- the index to retrieve, which must be zero
IndexOutOfBoundsException
- if the index is invalidpublic int getValue(int index)
The only index supported by this period is zero.
getValue
in interface ReadablePeriod
index
- the index to retrieve, which must be zero
IndexOutOfBoundsException
- if the index is invalidpublic int get(DurationFieldType type)
If the field type specified does not match the type used by this class then zero is returned.
get
in interface ReadablePeriod
type
- the field type to query, null returns zero
public boolean isSupported(DurationFieldType type)
isSupported
in interface ReadablePeriod
type
- the type to check, may be null which returns false
public Period toPeriod()
Period
object.
The period will use PeriodType.standard()
.
toPeriod
in interface ReadablePeriod
Period
representing the same number of dayspublic MutablePeriod toMutablePeriod()
MutablePeriod
.
This will always return a new MutablePeriod
with the same fields.
The period will use PeriodType.standard()
.
toMutablePeriod
in interface ReadablePeriod
public boolean equals(Object period)
PeriodType
can return true.
equals
in interface ReadablePeriod
period
- a readable period to check against
public int hashCode()
hashCode
in interface ReadablePeriod
public int compareTo(Object other)
compareTo
in interface Comparable
other
- the other period, must not be null
NullPointerException
- if the other period is null
ClassCastException
- if the other period is of a different type
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |