< prev index next >

src/java.base/share/classes/java/text/spi/NumberFormatProvider.java

Print this page


   1 /*
   2  * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  93      *     getAvailableLocales()}.
  94      * @return a general-purpose number formatter
  95      * @see java.text.NumberFormat#getNumberInstance(java.util.Locale)
  96      */
  97     public abstract NumberFormat getNumberInstance(Locale locale);
  98 
  99     /**
 100      * Returns a new <code>NumberFormat</code> instance which formats
 101      * percentage values for the specified locale.
 102      *
 103      * @param locale the desired locale
 104      * @exception NullPointerException if <code>locale</code> is null
 105      * @exception IllegalArgumentException if <code>locale</code> isn't
 106      *     one of the locales returned from
 107      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 108      *     getAvailableLocales()}.
 109      * @return a percent formatter
 110      * @see java.text.NumberFormat#getPercentInstance(java.util.Locale)
 111      */
 112     public abstract NumberFormat getPercentInstance(Locale locale);

































 113 }
   1 /*
   2  * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  93      *     getAvailableLocales()}.
  94      * @return a general-purpose number formatter
  95      * @see java.text.NumberFormat#getNumberInstance(java.util.Locale)
  96      */
  97     public abstract NumberFormat getNumberInstance(Locale locale);
  98 
  99     /**
 100      * Returns a new <code>NumberFormat</code> instance which formats
 101      * percentage values for the specified locale.
 102      *
 103      * @param locale the desired locale
 104      * @exception NullPointerException if <code>locale</code> is null
 105      * @exception IllegalArgumentException if <code>locale</code> isn't
 106      *     one of the locales returned from
 107      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 108      *     getAvailableLocales()}.
 109      * @return a percent formatter
 110      * @see java.text.NumberFormat#getPercentInstance(java.util.Locale)
 111      */
 112     public abstract NumberFormat getPercentInstance(Locale locale);
 113     
 114     /**
 115      * Returns a new {@code NumberFormat} instance which formats
 116      * a number in its compact form for the specified
 117      * {@code locale} and {@code formatStyle}.
 118      * 
 119      * @implSpec The default implementation of this method throws
 120      * {@code UnSupportedOperationException}. Overriding the implementation
 121      * of this method returns the compact number formatter instance
 122      * of the given {@code locale} with specified {@code formatStyle}.
 123      *
 124      * @param locale the desired locale
 125      * @param formatStyle the style for formatting a number
 126      * @throws NullPointerException if {@code locale} or {@code formatStyle}
 127      *     is {@code null}
 128      * @throws IllegalArgumentException if {@code locale} is not
 129      *     one of the locales returned from
 130      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 131      *     getAvailableLocales()}.
 132      * @return a compact number formatter
 133      *
 134      * @see java.text.NumberFormat#getCompactNumberInstance(Locale,
 135      *                      NumberFormat.Style)
 136      * @since 12
 137      */
 138     public NumberFormat getCompactNumberInstance(Locale locale,
 139             NumberFormat.Style formatStyle) {
 140         throw new UnsupportedOperationException(
 141                 "The " + this.getClass().getName() + " should override this"
 142                 + " method to return compact number format instance of "
 143                 + locale + " locale and " + formatStyle + " style.");
 144     }
 145 
 146 }
< prev index next >