public class PeriodType
extends java.lang.Object
implements java.io.Serializable
The following implementations are provided:
PeriodType is thread-safe and immutable, and all subclasses must be as well.
Modifier and Type | Field and Description |
---|---|
private static PeriodType |
cDays |
private static PeriodType |
cDTime |
private static PeriodType |
cHours |
private static PeriodType |
cMillis |
private static PeriodType |
cMinutes |
private static PeriodType |
cMonths |
private static PeriodType |
cSeconds |
private static PeriodType |
cStandard |
private static PeriodType |
cTime |
private static java.util.Map<PeriodType,java.lang.Object> |
cTypes
Cache of all the known types.
|
private static PeriodType |
cWeeks |
private static PeriodType |
cYD |
private static PeriodType |
cYDTime |
private static PeriodType |
cYears |
private static PeriodType |
cYMD |
private static PeriodType |
cYMDTime |
private static PeriodType |
cYWD |
private static PeriodType |
cYWDTime |
(package private) static int |
DAY_INDEX |
(package private) static int |
HOUR_INDEX |
private int[] |
iIndices
The array of indices
|
private java.lang.String |
iName
The name of the type
|
private DurationFieldType[] |
iTypes
The array of types
|
(package private) static int |
MILLI_INDEX |
(package private) static int |
MINUTE_INDEX |
(package private) static int |
MONTH_INDEX |
(package private) static int |
SECOND_INDEX |
private static long |
serialVersionUID
Serialization version
|
(package private) static int |
WEEK_INDEX |
(package private) static int |
YEAR_INDEX |
Modifier | Constructor and Description |
---|---|
protected |
PeriodType(java.lang.String name,
DurationFieldType[] types,
int[] indices)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
addIndexedField(ReadablePeriod period,
int index,
int[] values,
int valueToAdd)
Adds to the indexed field part of the period.
|
static PeriodType |
days()
Gets a type that defines just the days field.
|
static PeriodType |
dayTime()
Gets a type that defines all standard fields from days downwards.
|
boolean |
equals(java.lang.Object obj)
Compares this type to another object.
|
static PeriodType |
forFields(DurationFieldType[] types)
Gets a period type that contains the duration types of the array.
|
DurationFieldType |
getFieldType(int index)
Gets the field type by index.
|
(package private) int |
getIndexedField(ReadablePeriod period,
int index)
Gets the indexed field part of the period.
|
java.lang.String |
getName()
Gets the name of the period type.
|
int |
hashCode()
Returns a hashcode based on the field types.
|
static PeriodType |
hours()
Gets a type that defines just the hours field.
|
int |
indexOf(DurationFieldType type)
Gets the index of the field in this period.
|
boolean |
isSupported(DurationFieldType type)
Checks whether the field specified is supported by this period.
|
static PeriodType |
millis()
Gets a type that defines just the millis field.
|
static PeriodType |
minutes()
Gets a type that defines just the minutes field.
|
static PeriodType |
months()
Gets a type that defines just the months field.
|
static PeriodType |
seconds()
Gets a type that defines just the seconds field.
|
(package private) boolean |
setIndexedField(ReadablePeriod period,
int index,
int[] values,
int newValue)
Sets the indexed field part of the period.
|
int |
size()
Gets the number of fields in the period type.
|
static PeriodType |
standard()
Gets a type that defines all standard fields.
|
static PeriodType |
time()
Gets a type that defines all standard time fields.
|
java.lang.String |
toString()
Gets a debugging to string.
|
static PeriodType |
weeks()
Gets a type that defines just the weeks field.
|
PeriodType |
withDaysRemoved()
Returns a version of this PeriodType instance that does not support days.
|
private PeriodType |
withFieldRemoved(int indicesIndex,
java.lang.String name)
Removes the field specified by indices index.
|
PeriodType |
withHoursRemoved()
Returns a version of this PeriodType instance that does not support hours.
|
PeriodType |
withMillisRemoved()
Returns a version of this PeriodType instance that does not support milliseconds.
|
PeriodType |
withMinutesRemoved()
Returns a version of this PeriodType instance that does not support minutes.
|
PeriodType |
withMonthsRemoved()
Returns a version of this PeriodType instance that does not support months.
|
PeriodType |
withSecondsRemoved()
Returns a version of this PeriodType instance that does not support seconds.
|
PeriodType |
withWeeksRemoved()
Returns a version of this PeriodType instance that does not support weeks.
|
PeriodType |
withYearsRemoved()
Returns a version of this PeriodType instance that does not support years.
|
static PeriodType |
yearDay()
Gets a type that defines the year and day fields.
|
static PeriodType |
yearDayTime()
Gets a type that defines all standard fields except months and weeks.
|
static PeriodType |
yearMonthDay()
Gets a type that defines the year, month and day fields.
|
static PeriodType |
yearMonthDayTime()
Gets a type that defines all standard fields except weeks.
|
static PeriodType |
years()
Gets a type that defines just the years field.
|
static PeriodType |
yearWeekDay()
Gets a type that defines year, week and day fields.
|
static PeriodType |
yearWeekDayTime()
Gets a type that defines all standard fields except months.
|
private static final long serialVersionUID
private static final java.util.Map<PeriodType,java.lang.Object> cTypes
static int YEAR_INDEX
static int MONTH_INDEX
static int WEEK_INDEX
static int DAY_INDEX
static int HOUR_INDEX
static int MINUTE_INDEX
static int SECOND_INDEX
static int MILLI_INDEX
private static PeriodType cStandard
private static PeriodType cYMDTime
private static PeriodType cYMD
private static PeriodType cYWDTime
private static PeriodType cYWD
private static PeriodType cYDTime
private static PeriodType cYD
private static PeriodType cDTime
private static PeriodType cTime
private static PeriodType cYears
private static PeriodType cMonths
private static PeriodType cWeeks
private static PeriodType cDays
private static PeriodType cHours
private static PeriodType cMinutes
private static PeriodType cSeconds
private static PeriodType cMillis
private final java.lang.String iName
private final DurationFieldType[] iTypes
private final int[] iIndices
protected PeriodType(java.lang.String name, DurationFieldType[] types, int[] indices)
name
- the nametypes
- the typesindices
- the indicespublic static PeriodType standard()
public static PeriodType yearMonthDayTime()
public static PeriodType yearMonthDay()
public static PeriodType yearWeekDayTime()
public static PeriodType yearWeekDay()
public static PeriodType yearDayTime()
public static PeriodType yearDay()
public static PeriodType dayTime()
public static PeriodType time()
public static PeriodType years()
public static PeriodType months()
public static PeriodType weeks()
public static PeriodType days()
public static PeriodType hours()
public static PeriodType minutes()
public static PeriodType seconds()
public static PeriodType millis()
public static PeriodType forFields(DurationFieldType[] types)
Only the 8 standard duration field types are supported.
types
- the types to include in the array.public java.lang.String getName()
public int size()
public DurationFieldType getFieldType(int index)
index
- the index to retrievejava.lang.IndexOutOfBoundsException
- if the index is invalidpublic boolean isSupported(DurationFieldType type)
type
- the type to check, may be null which returns falsepublic int indexOf(DurationFieldType type)
type
- the type to check, may be null which returns -1public java.lang.String toString()
toString
in class java.lang.Object
int getIndexedField(ReadablePeriod period, int index)
period
- the period to queryindex
- the index to useboolean setIndexedField(ReadablePeriod period, int index, int[] values, int newValue)
period
- the period to queryindex
- the index to usevalues
- the array to populatenewValue
- the value to setjava.lang.UnsupportedOperationException
- if not supportedboolean addIndexedField(ReadablePeriod period, int index, int[] values, int valueToAdd)
period
- the period to queryindex
- the index to usevalues
- the array to populatevalueToAdd
- the value to addjava.lang.UnsupportedOperationException
- if not supportedpublic PeriodType withYearsRemoved()
public PeriodType withMonthsRemoved()
public PeriodType withWeeksRemoved()
public PeriodType withDaysRemoved()
public PeriodType withHoursRemoved()
public PeriodType withMinutesRemoved()
public PeriodType withSecondsRemoved()
public PeriodType withMillisRemoved()
private PeriodType withFieldRemoved(int indicesIndex, java.lang.String name)
indicesIndex
- the index to removename
- the name additionpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to compare topublic int hashCode()
hashCode
in class java.lang.Object