Class HistoricChronology.DayOfYearRule
- java.lang.Object
-
- javax.time.calendar.CalendricalRule<T>
-
- javax.time.calendar.DateTimeFieldRule<java.lang.Integer>
-
- javax.time.i18n.HistoricChronology.DayOfYearRule
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<CalendricalRule<?>>
,java.util.Comparator<Calendrical>
- Enclosing class:
- HistoricChronology
private static final class HistoricChronology.DayOfYearRule extends DateTimeFieldRule<java.lang.Integer> implements java.io.Serializable
Rule implementation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.time.calendar.DateTimeFieldRule
DateTimeFieldRule.TextStore
-
-
Field Summary
Fields Modifier and Type Field Description private HistoricChronology
chrono
The chronology.private static long
serialVersionUID
A serialization identifier for this class.
-
Constructor Summary
Constructors Modifier Constructor Description private
DayOfYearRule(HistoricChronology chrono)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Integer
derive(Calendrical calendrical)
Derives the value of this rule from a calendrical.int
getMaximumValue(Calendrical calendrical)
Gets the minimum value that the field can take using the specified calendrical information to refine the accuracy of the response.int
getSmallestMaximumValue()
Gets the smallest possible maximum value that the field can take.protected void
merge(CalendricalMerger merger)
Merges this field with other fields to form higher level fields.-
Methods inherited from class javax.time.calendar.DateTimeFieldRule
checkValue, checkValue, convertFractionToInt, convertIntToFraction, convertIntToValue, convertValueToInt, createTextStores, getInt, getInteger, getLargestMinimumValue, getMaximumValue, getMinimumValue, getMinimumValue, getText, getTextStore, isFixedValueSet, isValidValue, isValidValue
-
Methods inherited from class javax.time.calendar.CalendricalRule
compare, compareTo, deriveValueFor, deriveValueFrom, equals, getChronology, getID, getName, getPeriodRange, getPeriodUnit, getReifiedType, getValue, getValueChecked, hashCode, interpret, reify, toString
-
-
-
-
Field Detail
-
chrono
private final HistoricChronology chrono
The chronology.
-
serialVersionUID
private static final long serialVersionUID
A serialization identifier for this class.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DayOfYearRule
private DayOfYearRule(HistoricChronology chrono)
Constructor.
-
-
Method Detail
-
getSmallestMaximumValue
public int getSmallestMaximumValue()
Description copied from class:DateTimeFieldRule
Gets the smallest possible maximum value that the field can take.The default implementation returns
DateTimeFieldRule.getMaximumValue()
. Subclasses must override this as necessary.- Overrides:
getSmallestMaximumValue
in classDateTimeFieldRule<java.lang.Integer>
- Returns:
- the smallest possible maximum value for this field
-
getMaximumValue
public int getMaximumValue(Calendrical calendrical)
Description copied from class:DateTimeFieldRule
Gets the minimum value that the field can take using the specified calendrical information to refine the accuracy of the response.The result of this method will still be inaccurate if there is insufficient information in the calendrical.
For example, if this field is the ISO day-of-month field, then the number of days in the month varies depending on the month and year. If both the month and year can be derived from the calendrical, then the maximum value returned will be accurate. Otherwise the 'best guess' value from
DateTimeFieldRule.getMaximumValue()
will be returned.The default implementation returns
DateTimeFieldRule.getMaximumValue()
. Subclasses must override this as necessary.- Overrides:
getMaximumValue
in classDateTimeFieldRule<java.lang.Integer>
- Parameters:
calendrical
- context calendrical, not null- Returns:
- the minimum value of the field given the context
-
derive
protected java.lang.Integer derive(Calendrical calendrical)
Description copied from class:CalendricalRule
Derives the value of this rule from a calendrical.This method derives the value for this field from other fields in the calendrical without directly querying the calendrical for the value.
For example, if this field is quarter-of-year, then the value can be derived from month-of-year.
The implementation only needs to derive the value based on its immediate parents. The use of
Calendrical.get(javax.time.calendar.CalendricalRule<T>)
will extract any further parents on demand.A typical implementation of this method obtains the parent value and performs a calculation. For example, here is a simple implementation for the quarter-of-year field:
Integer moyVal = calendrical.get(ISOChronology.monthOfYearRule()); return (moyVal != null ? ((moyVal - 1) % 4) + 1) : null;
This method is designed to be overridden in subclasses. The subclass implementation must be thread-safe. The subclass implementation must not request the value of this rule from the specified calendrical, otherwise a stack overflow error will occur.
- Overrides:
derive
in classCalendricalRule<java.lang.Integer>
- Parameters:
calendrical
- the calendrical to derive from, not null- Returns:
- the derived value, null if unable to derive
-
merge
protected void merge(CalendricalMerger merger)
Description copied from class:CalendricalRule
Merges this field with other fields to form higher level fields.The aim of this method is to assist in the process of extracting the most date-time information possible from a map of field-value pairs. The merging process is controlled by the mutable merger instance and the input and output of the this merge are held there.
Subclasses that override this method may use methods on the merger to obtain the values to merge. The value is guaranteed to be available for this field if this method is called.
If the override successfully merged some fields then the following must be performed. The merged field must be stored using
CalendricalMerger.storeMerged(javax.time.calendar.CalendricalRule<T>, T)
. Each field used in the merge must be marked as being used by callingCalendricalMerger.removeProcessed(javax.time.calendar.CalendricalRule<?>)
.An example to merge two fields into one - hour of AM/PM and AM/PM:
Integer hapVal = merger.getValue(ISOChronology.hourOfAmPmRule()); if (hapVal != null) { AmPmOfDay amPm = merger.getValue(this); int hourOfDay = MathUtils.safeAdd(MathUtils.safeMultiply(amPm, 12), hapVal); merger.storeMerged(ISOChronology.hourOfDayRule(), hourOfDay); merger.removeProcessed(this); merger.removeProcessed(ISOChronology.hourOfAmPmRule()); }
- Overrides:
merge
in classCalendricalRule<java.lang.Integer>
- Parameters:
merger
- the merger instance controlling the merge process, not null
-
-