| MissingFormatArgumentException.java |
1 /*
2 * %W% %E%
3 *
4 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
5 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6 */
7
8 package java.util;
9
10 /**
11 * Unchecked exception thrown when there is a format specifier which does not
12 * have a corresponding argument or if an argument index refers to an argument
13 * that does not exist.
14 *
15 * <p> Unless otherwise specified, passing a <tt>null</tt> argument to any
16 * method or constructor in this class will cause a {@link
17 * NullPointerException} to be thrown.
18 *
19 * @version %I%, %G%
20 * @since 1.5
21 */
22 public class MissingFormatArgumentException extends IllegalFormatException {
23
24 private static final long serialVersionUID = 19190115L;
25
26 private String s;
27
28 /**
29 * Constructs an instance of this class with the unmatched format
30 * specifier.
31 *
32 * @param s
33 * Format specifier which does not have a corresponding argument
34 */
35 public MissingFormatArgumentException(String s) {
36 if (s == null)
37 throw new NullPointerException();
38 this.s = s;
39 }
40
41 /**
42 * Returns the unmatched format specifier.
43 *
44 * @return The unmatched format specifier
45 */
46 public String getFormatSpecifier() {
47 return s;
48 }
49
50 public String getMessage() {
51 return "Format specifier '" + s + "'";
52 }
53 }
54