< prev index next >
src/java.base/share/classes/java/text/spi/NumberFormatProvider.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 108,113 ****
--- 108,146 ----
* getAvailableLocales()}.
* @return a percent formatter
* @see java.text.NumberFormat#getPercentInstance(java.util.Locale)
*/
public abstract NumberFormat getPercentInstance(Locale locale);
+
+ /**
+ * Returns a new {@code NumberFormat} instance which formats
+ * a number in its compact form for the specified
+ * {@code locale} and {@code formatStyle}.
+ *
+ * @implSpec The default implementation of this method throws
+ * {@code UnSupportedOperationException}. Overriding the implementation
+ * of this method returns the compact number formatter instance
+ * of the given {@code locale} with specified {@code formatStyle}.
+ *
+ * @param locale the desired locale
+ * @param formatStyle the style for formatting a number
+ * @throws NullPointerException if {@code locale} or {@code formatStyle}
+ * is {@code null}
+ * @throws IllegalArgumentException if {@code locale} is not
+ * one of the locales returned from
+ * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
+ * getAvailableLocales()}.
+ * @return a compact number formatter
+ *
+ * @see java.text.NumberFormat#getCompactNumberInstance(Locale,
+ * NumberFormat.Style)
+ * @since 12
+ */
+ public NumberFormat getCompactNumberInstance(Locale locale,
+ NumberFormat.Style formatStyle) {
+ throw new UnsupportedOperationException(
+ "The " + this.getClass().getName() + " should override this"
+ + " method to return compact number format instance of "
+ + locale + " locale and " + formatStyle + " style.");
+ }
+
}
< prev index next >