Package com.ibm.icu.impl.duration
Class BasicDurationFormatterFactory
- java.lang.Object
-
- com.ibm.icu.impl.duration.BasicDurationFormatterFactory
-
- All Implemented Interfaces:
DurationFormatterFactory
class BasicDurationFormatterFactory extends java.lang.Object implements DurationFormatterFactory
Abstract factory object used to create DurationFormatters. DurationFormatters are immutable once created.Setters on the factory mutate the factory and return it, for chaining.
Subclasses override getFormatter to return a custom DurationFormatter.
-
-
Field Summary
Fields Modifier and Type Field Description private PeriodBuilder
builder
private BasicDurationFormatter
f
private DateFormatter
fallback
private long
fallbackLimit
private PeriodFormatter
formatter
private java.lang.String
localeName
private BasicPeriodFormatterService
ps
private java.util.TimeZone
timeZone
-
Constructor Summary
Constructors Constructor Description BasicDurationFormatterFactory(BasicPeriodFormatterService ps)
Create a default formatter for the current locale and time zone.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected BasicDurationFormatter
createFormatter()
Create the formatter.DateFormatter
getFallback()
Return the current fallback formatter.long
getFallbackLimit()
Return the current fallback formatter limitDurationFormatter
getFormatter()
Return a formatter based on this factory's current settings.java.lang.String
getLocaleName()
Return the current locale name.PeriodBuilder
getPeriodBuilder()
Return the current builder.PeriodFormatter
getPeriodFormatter()
Return the current period formatter.java.util.TimeZone
getTimeZone()
Return the current locale name.protected void
reset()
Clear the cached formatter.DurationFormatterFactory
setFallback(DateFormatter fallback)
Set a fallback formatter for durations over a given limit.DurationFormatterFactory
setFallbackLimit(long fallbackLimit)
Set a fallback limit for durations over a given limit.DurationFormatterFactory
setLocale(java.lang.String localeName)
Set the name of the locale that will be used when creating new formatters.DurationFormatterFactory
setPeriodBuilder(PeriodBuilder builder)
Set the builder used by the factory.DurationFormatterFactory
setPeriodFormatter(PeriodFormatter formatter)
Set the period formatter used by the factory.DurationFormatterFactory
setTimeZone(java.util.TimeZone timeZone)
Set the name of the locale that will be used when creating new formatters.
-
-
-
Field Detail
-
ps
private BasicPeriodFormatterService ps
-
formatter
private PeriodFormatter formatter
-
builder
private PeriodBuilder builder
-
fallback
private DateFormatter fallback
-
fallbackLimit
private long fallbackLimit
-
localeName
private java.lang.String localeName
-
timeZone
private java.util.TimeZone timeZone
-
f
private BasicDurationFormatter f
-
-
Constructor Detail
-
BasicDurationFormatterFactory
BasicDurationFormatterFactory(BasicPeriodFormatterService ps)
Create a default formatter for the current locale and time zone.
-
-
Method Detail
-
setPeriodFormatter
public DurationFormatterFactory setPeriodFormatter(PeriodFormatter formatter)
Set the period formatter used by the factory. New formatters created with this factory will use the given period formatter.- Specified by:
setPeriodFormatter
in interfaceDurationFormatterFactory
- Parameters:
formatter
- the formatter to use- Returns:
- this BasicDurationFormatterFactory
-
setPeriodBuilder
public DurationFormatterFactory setPeriodBuilder(PeriodBuilder builder)
Set the builder used by the factory. New formatters created with this factory will use the given locale.- Specified by:
setPeriodBuilder
in interfaceDurationFormatterFactory
- Parameters:
builder
- the builder to use- Returns:
- this BasicDurationFormatterFactory
-
setFallback
public DurationFormatterFactory setFallback(DateFormatter fallback)
Set a fallback formatter for durations over a given limit.- Specified by:
setFallback
in interfaceDurationFormatterFactory
- Parameters:
fallback
- the fallback formatter to use, or null- Returns:
- this BasicDurationFormatterFactory
-
setFallbackLimit
public DurationFormatterFactory setFallbackLimit(long fallbackLimit)
Set a fallback limit for durations over a given limit.- Specified by:
setFallbackLimit
in interfaceDurationFormatterFactory
- Parameters:
fallbackLimit
- the fallback limit to use, or 0 if none is desired.- Returns:
- this BasicDurationFormatterFactory
-
setLocale
public DurationFormatterFactory setLocale(java.lang.String localeName)
Set the name of the locale that will be used when creating new formatters.- Specified by:
setLocale
in interfaceDurationFormatterFactory
- Parameters:
localeName
- the name of the Locale- Returns:
- this BasicDurationFormatterFactory
-
setTimeZone
public DurationFormatterFactory setTimeZone(java.util.TimeZone timeZone)
Set the name of the locale that will be used when creating new formatters.- Specified by:
setTimeZone
in interfaceDurationFormatterFactory
- Parameters:
timeZone
- The time zone to use.- Returns:
- this BasicDurationFormatterFactory
-
getFormatter
public DurationFormatter getFormatter()
Return a formatter based on this factory's current settings.- Specified by:
getFormatter
in interfaceDurationFormatterFactory
- Returns:
- a BasicDurationFormatter
-
getPeriodFormatter
public PeriodFormatter getPeriodFormatter()
Return the current period formatter.- Returns:
- the current period formatter
-
getPeriodBuilder
public PeriodBuilder getPeriodBuilder()
Return the current builder.- Returns:
- the current builder
-
getFallback
public DateFormatter getFallback()
Return the current fallback formatter.- Returns:
- the fallback formatter, or null if there is no fallback formatter
-
getFallbackLimit
public long getFallbackLimit()
Return the current fallback formatter limit- Returns:
- the limit, or 0 if there is no fallback.
-
getLocaleName
public java.lang.String getLocaleName()
Return the current locale name.- Returns:
- the current locale name
-
getTimeZone
public java.util.TimeZone getTimeZone()
Return the current locale name.- Returns:
- the current locale name
-
createFormatter
protected BasicDurationFormatter createFormatter()
Create the formatter. All local fields are already initialized.
-
reset
protected void reset()
Clear the cached formatter. Subclasses must call this if their state has changed. This is automatically invoked by setBuilder, setFormatter, setFallback, setLocaleName, and setTimeZone
-
-