src/share/classes/java/text/NumberFormat.java
Print this page
@@ -281,14 +281,24 @@
* @exception ArithmeticException if rounding is needed with rounding
* mode being set to RoundingMode.UNNECESSARY
* @see java.text.Format#format
*/
public final String format(double number) {
+ // Use fast-path for double result if that works
+ String result = fastFormat(number);
+ if (result != null) return result;
+
return format(number, new StringBuffer(),
DontCareFieldPosition.INSTANCE).toString();
}
+ /*
+ * fastFormat() is supposed to be implemented in concrete subclasses only.
+ * Default implem always returns null.
+ */
+ String fastFormat(double number) { return null; }
+
/**
* Specialization of format.
* @exception ArithmeticException if rounding is needed with rounding
* mode being set to RoundingMode.UNNECESSARY
* @see java.text.Format#format