Interface ChronoMerger<T>

Type Parameters:
T - generic type of time context (compatible to ChronoEntity)
All Known Implementing Classes:
BridgeChronology, CalendarFamily, Chronology, TimeAxis

public interface ChronoMerger<T>

Merges any set of chronological informations to a new chronological entity.

This interface abstracts the knowledge of the chronology how to construct a new entity based on any set of chronological informations. It is mainly used by a parser in order to interprete textual representations of chronological entities.

Using this low-level-interface is usually reserved for Time4J and serves for internal format support. However, for constructing new calendar systems implementing this interface is an essential part for parsing support. Implementation note: All classes of this type must be immutable.

Author:
Meno Hochschild
  • Method Details

    • createFrom

      T createFrom(TimeSource<?> clock, AttributeQuery attributes)

      Creates 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.

      Parameters:
      clock - source for current time
      attributes - configuration attributes which might contain the timezone to translate current time to local time
      Returns:
      new time context or null if given data are insufficient
    • createFrom

      T createFrom(ChronoEntity<?> entity, AttributeQuery attributes, boolean lenient, boolean preparsing)

      Creates 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.

      Parameters:
      entity - any chronological entity like parsed elements with their values
      attributes - configuration attributes given by parser
      lenient - controls the leniency how to interprete invalid values
      preparsing - preparsing phase active?
      Returns:
      new time context or null if given data are insufficient
      Throws:
      IllegalArgumentException - in any case of inconsistent data
      Since:
      3.15/4.12
      See Also:
      ValidationElement.ERROR_MESSAGE
    • preformat

      default 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.

      Parameters:
      context - actual chronological context to be formatted
      attributes - controls attributes during formatting
      Returns:
      replacement entity which will finally be used for formatting
      Throws:
      IllegalArgumentException - in any case of inconsistent data
    • preparser

      default Chronology<?> preparser()

      This method defines a child chronology which can preparse a chronological text.

      Returns:
      preparsing chronology or null (default)
    • getFormatPattern

      @Deprecated default String getFormatPattern(DisplayStyle style, Locale locale)

      Defines a CLDR-compatible localized format pattern.

      Parameters:
      style - format style
      locale - language and country setting
      Returns:
      localized format pattern
      Throws:
      UnsupportedOperationException - if given style is not supported or if no localized format pattern support is available
      Since:
      3.10/4.7
      See Also:
      LocalizedPatternSupport
    • getFormatPattern

      default String getFormatPattern(FormatStyle style, Locale locale)

      Defines a CLDR-compatible localized format pattern.

      The default implementation always throws an UnsupportedOperationException.

      Parameters:
      style - format style
      locale - language and country setting
      Returns:
      localized format pattern
      Throws:
      UnsupportedOperationException - if given style is not supported or if no localized format pattern support is available
      Since:
      5.8
      See Also:
      LocalizedPatternSupport
    • getDefaultStartOfDay

      default StartOfDay getDefaultStartOfDay()

      Determines the default start of day.

      Returns:
      start of day
      Since:
      3.11/4.8
    • getDefaultPivotYear

      default int getDefaultPivotYear()

      Determines the default pivot year which might be calendar specific and serves for the formatting of two-digit-years.

      Most calendar chronologies should choose a pivot year 20 years in the future. The standard implementation is based on the gregorian calendar. If an implementation returns the value 100 then the formatting of two-digit-years is effectively switched off.

      Returns:
      default pivot year (must not be smaller than 100)
      Since:
      3.32/4.27