T - generic type compatible to ChronoEntitypublic class Chronology<T extends ChronoEntity<T>> extends java.lang.Object implements ChronoMerger<T>
Represents a system of chronological elements which form any kind of temporal value.
| Modifier and Type | Class and Description |
|---|---|
static class |
Chronology.Builder<T extends ChronoEntity<T>>
Builder for creating a new chronology without any time axis.
|
| Modifier and Type | Method and Description |
|---|---|
T |
createFrom(ChronoEntity<?> entity,
AttributeQuery attributes,
boolean preparsing)
Creates a new entity of type T based on given chronological
data.
|
T |
createFrom(TimeSource<?> clock,
AttributeQuery attributes)
Creates a new entity which reflects current time.
|
CalendarSystem<T> |
getCalendarSystem()
Returns the associated calendar system if available.
|
CalendarSystem<T> |
getCalendarSystem(java.lang.String variant)
Returns the calendar system for given calendar variant if available.
|
java.lang.Class<T> |
getChronoType()
Returns the chronological type.
|
java.util.List<ChronoExtension> |
getExtensions()
Returns all registered chronological extensions.
|
java.util.Set<ChronoElement<?>> |
getRegisteredElements()
Returns all registered chronological elements.
|
boolean |
hasCalendarSystem()
Queries if this chronology has a calendar system.
|
boolean |
isRegistered(ChronoElement<?> element)
Queries if given chronological element is registered together
with its element rule.
|
boolean |
isSupported(ChronoElement<?> element)
Queries if given chronological element is supported by this
chronology.
|
static <T extends ChronoEntity<T>> |
lookup(java.lang.Class<T> chronoType)
Returns a typed singleton per
ChronoEntity-class. |
ChronoDisplay |
preformat(T context,
AttributeQuery attributes)
Transforms the current context/entity into another set of chronological
values which finally shall be formatted using given attributes.
|
Chronology<?> |
preparser()
This method defines a child chronology which can preparse
a chronological text.
|
public java.lang.Class<T> getChronoType()
Returns the chronological type.
public java.util.Set<ChronoElement<?>> getRegisteredElements()
Returns all registered chronological elements.
public boolean isRegistered(ChronoElement<?> element)
Queries if given chronological element is registered together with its element rule.
element - element to be asked (optional)true if registered else falsepublic boolean isSupported(ChronoElement<?> element)
Queries if given chronological element is supported by this chronology.
The element will be supported if it is either registered or defines a suitable element rule for this chronology.
element - element to be asked (optional)true if supported else falsepublic T createFrom(TimeSource<?> clock, AttributeQuery attributes)
ChronoMergerCreates a new entity which reflects current time.
In a date-only chronology this method will create the current date using the necessary timezone contained in given attributes.
createFrom in interface ChronoMerger<T extends ChronoEntity<T>>clock - source for current timeattributes - configuration attributes which might contain
the timezone to translate current time to
local timenull if given data are insufficientpublic T createFrom(ChronoEntity<?> entity, AttributeQuery attributes, boolean preparsing)
ChronoMergerCreates a new entity of type T based on given chronological data.
Typically the method will query the given entity with
different priorities for elements which can compose a new chronological
entity (per group). For example a calendar date can be composed either
by epoch days or the group (year)-(month)-(day-of-month) or the group
(year)-(day-of-year) etc.
A text parser will call this method after having resolved a text
into single chronological elements and values. Implementations should
always validate the parsed values. In case of error, they are free to
either throw an IllegalArgumentException or to generate
and to save an error message by mean of the expression
entity.with(ValidationElement.ERROR_MESSAGE, message.
createFrom in interface ChronoMerger<T extends ChronoEntity<T>>entity - any chronological entity like parsed
elements with their valuesattributes - configuration attributes given by parserpreparsing - preparsing phase active?null if given data are insufficientValidationElement.ERROR_MESSAGEpublic ChronoDisplay preformat(T context, AttributeQuery attributes)
ChronoMergerTransforms the current context/entity into another set of chronological values which finally shall be formatted using given attributes.
preformat in interface ChronoMerger<T extends ChronoEntity<T>>context - actual chronological context to be formattedattributes - controls attributes during formattingpublic Chronology<?> preparser()
ChronoMergerThis method defines a child chronology which can preparse a chronological text.
preparser in interface ChronoMerger<T extends ChronoEntity<T>>nullpublic java.util.List<ChronoExtension> getExtensions()
Returns all registered chronological extensions.
This method will be called by format-API in order to collect all extension elements which are relevant for formatting.
public boolean hasCalendarSystem()
Queries if this chronology has a calendar system.
true if this chronology has a calendar system else falsegetCalendarSystem()public CalendarSystem<T> getCalendarSystem()
Returns the associated calendar system if available.
nullChronoException - if the calendar system is unavailable or if there is more than one varianthasCalendarSystem()public CalendarSystem<T> getCalendarSystem(java.lang.String variant)
Returns the calendar system for given calendar variant if available.
variant - name of calendar variantnullChronoException - if a calendar system is unavailable for given variant (invalid variant name)CalendarVariant.getVariant()public static <T extends ChronoEntity<T>> Chronology<T> lookup(java.lang.Class<T> chronoType)
Returns a typed singleton per ChronoEntity-class.
T - generic type of time contextchronoType - chronological typenull if not found