Class FastChoiceFormat

  • All Implemented Interfaces:
    Serializable, Cloneable, FastFormat

    public class FastChoiceFormat
    extends Object
    implements FastFormat
    A wrapper around the java.text.ChoiceFormat class. This wrapper limits the possible interactions with the wrapped format class and therefore eliminates the need to clone the choice format whenever the wrapper is cloned.
    Author:
    Thomas Morgner
    See Also:
    Serialized Form
    • Constructor Detail

      • FastChoiceFormat

        public FastChoiceFormat​(String pattern)
        Creates a new ChoiceFormat with the given pattern and the default locale.
        Parameters:
        pattern - the pattern.
      • FastChoiceFormat

        public FastChoiceFormat​(String pattern,
                                Locale locale)
        Creates a new ChoiceFormat with the given pattern and locale. As the local is not used anywhere, this has no impact on the format itself.
        Parameters:
        pattern - the pattern.
        locale - the locale.
    • Method Detail

      • getLocale

        public Locale getLocale()
        Returns the current locale of the formatter.
        Specified by:
        getLocale in interface FastFormat
        Returns:
        the current locale, never null.
      • getPattern

        public String getPattern()
        Returns the currently active pattern.
        Returns:
        the locale.
      • format

        public String format​(Object parameters)
        Formats the given object using the choice-pattern.
        Specified by:
        format in interface FastFormat
        Parameters:
        parameters - the parameters, usually a Number- or Date object.
        Returns:
        the formatted text.