< prev index next >

src/java.base/share/classes/java/text/ChoiceFormat.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1996, 2013, 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) 1996, 2017, 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
*** 170,179 **** --- 170,181 ---- private static final long serialVersionUID = 1795184449645032964L; /** * Sets the pattern. * @param newPattern See the class description. + * @exception NullPointerException if {@code newPattern} + * is {@code null} */ public void applyPattern(String newPattern) { StringBuffer[] segments = new StringBuffer[2]; for (int i = 0; i < segments.length; ++i) { segments[i] = new StringBuffer();
*** 307,316 **** --- 309,320 ---- /** * Constructs with limits and corresponding formats based on the pattern. * * @param newPattern the new pattern string + * @exception NullPointerExcpetion if {@code newPattern} is + * {@code null} * @see #applyPattern */ public ChoiceFormat(String newPattern) { applyPattern(newPattern); }
*** 318,327 **** --- 322,333 ---- /** * Constructs with the limits and the corresponding formats. * * @param limits limits in ascending order * @param formats corresponding format strings + * @exception NullPointerException if {@code limits} or {@code formats} + * is {@code null} * @see #setChoices */ public ChoiceFormat(double[] limits, String[] formats) { setChoices(limits, formats); }
*** 337,346 **** --- 343,354 ---- * @param formats are the formats you want to use for each limit. * They can be either Format objects or Strings. * When formatting with object Y, * if the object is a NumberFormat, then ((NumberFormat) Y).format(X) * is called. Otherwise Y.toString() is called. + * @exception NullPointerException if {@code limits} or + * {@code formats} is {@code null} */ public void setChoices(double[] limits, String formats[]) { if (limits.length != formats.length) { throw new IllegalArgumentException( "Array and limit arrays must be of the same length.");
*** 384,393 **** --- 392,403 ---- /** * Returns pattern with formatted double. * @param number number to be formatted and substituted. * @param toAppendTo where text is appended. * @param status ignore no useful status is returned. + * @exception NullPointerException if {@code toAppendTo} + * is {@code null} */ public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition status) { // find the number int i;
*** 412,421 **** --- 422,434 ---- * occurred, status.index is set to the first unparsed character * in the source text. On exit, if an error did occur, * status.index is unchanged and status.errorIndex is set to the * first index of the character that caused the parse to fail. * @return A Number representing the value of the number parsed. + * @exception NullPointerException if {@code status} is {@code null} + * or if {@code text} is {@code null} and the list of + * choice strings is not empty. */ public Number parse(String text, ParsePosition status) { // find the best number (defined as the one with the longest parse) int start = status.index; int furthest = start;
< prev index next >