Class PluralFormat


  • public class PluralFormat
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      PluralFormat​(java.lang.String pattern)  
      PluralFormat​(java.util.Locale locale, java.lang.String pattern)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void applyPattern​(java.lang.String pattern)
      Sets the pattern used by this plural format.
      java.lang.String format​(double number)  
      java.lang.StringBuilder format​(java.lang.Object number, java.lang.StringBuilder toAppendTo, java.text.FieldPosition pos)
      Formats a plural message for a given number and appends the formatted message to the given StringBuffer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PluralFormat

        public PluralFormat​(java.lang.String pattern)
      • PluralFormat

        public PluralFormat​(java.util.Locale locale,
                            java.lang.String pattern)
    • Method Detail

      • applyPattern

        public void applyPattern​(java.lang.String pattern)
        Sets the pattern used by this plural format. The method parses the pattern and creates a map of format strings for the plural rules. Patterns and their interpretation are specified in the class description.
        Parameters:
        pattern - the pattern for this plural format.
        Throws:
        java.lang.IllegalArgumentException - if the pattern is invalid.
      • format

        public final java.lang.String format​(double number)
      • format

        public java.lang.StringBuilder format​(java.lang.Object number,
                                              java.lang.StringBuilder toAppendTo,
                                              java.text.FieldPosition pos)
        Formats a plural message for a given number and appends the formatted message to the given StringBuffer.
        Parameters:
        number - a number object (instance of Number for which the plural message should be formatted. If no pattern has been applied to this PluralFormat object yet, the formatted number will be returned. Note: If this object is not an instance of Number, the toAppendTo will not be modified.
        toAppendTo - the formatted message will be appended to this StringBuffer.
        pos - will be ignored by this method.
        Returns:
        the string buffer passed in as toAppendTo, with formatted text appended.
        Throws:
        java.lang.IllegalArgumentException - if number is not an instance of Number