Interface ChronoExtension
Defines a configuration-dependent extension of the chronological
elements of a Chronology used in formatting and parsing.
- Author:
- Meno Hochschild
-
Method Summary
Modifier and TypeMethodDescriptionbooleanWill be called by ajava.util.ServiceLoaderin order to determine if the given chronological type should register this extension or not.default booleancanResolve(ChronoElement<?> element)Gives a hint to the parser if the element in question can be resolved byresolve().Set<ChronoElement<?>>getElements(Locale locale, AttributeQuery attributes)Returns the element set for given configuration.ChronoEntity<?>resolve(ChronoEntity<?> entity, Locale locale, AttributeQuery attributes)Updates the given value source if necessary in order to resolve the values of extension elements to values of standard elements.
-
Method Details
-
accept
Will be called by a
java.util.ServiceLoaderin order to determine if the given chronological type should register this extension or not.- Parameters:
chronoType- chronological type- Returns:
trueif given type should register this extension elsefalse- Since:
- 3.0
-
getElements
Returns the element set for given configuration.
An empty
Setindicates that this extension is not relevant for the given configuration.- Parameters:
locale- language and country settingattributes- global configuration attributes of formatter- Returns:
- extended element model
-
resolve
Updates the given value source if necessary in order to resolve the values of extension elements to values of standard elements.
Implementations are allowed to use
nullas pseudo-value in order to delete an element from given source via the expressionentity.with(element, null). Note: The argument has exceptionally no chronology.- Parameters:
entity- any kind of map from chronological elements to their values (note that the main use case of parsed data has no chronology and allows the virtual valuenullto be set as indication for removing associated element)locale- language and country settingattributes- global configuration attributes of parser- Returns:
- eventually changed entity
- Throws:
IllegalArgumentException- if resolving fails due to inconsistencies- Since:
- 3.0
- See Also:
ChronoEntity.with(ChronoElement, V)
-
canResolve
Gives a hint to the parser if the element in question can be resolved by
resolve().This method serves for optimization purpose and helps the parser to decide if chronological extensions are needed at all during parsing. Subclasses should override this method in most cases.
- Parameters:
element- the element to be checked- Returns:
trueif this extension can resolve given element elsefalse- Since:
- 3.40/4.35
- See Also:
resolve(ChronoEntity, Locale, AttributeQuery)
-