1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements.  See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License.  You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package java.util;
18
19import java.io.Serializable;
20
21/**
22 * A {@code FormatFlagsConversionMismatchException} will be thrown if a
23 * conversion and the flags are incompatible.
24 *
25 * @see java.lang.RuntimeException
26 */
27public class FormatFlagsConversionMismatchException extends
28        IllegalFormatException implements Serializable {
29
30    private static final long serialVersionUID = 19120414L;
31
32    private String f;
33
34    private char c;
35
36    /**
37     * Constructs a new {@code FormatFlagsConversionMismatchException} with the
38     * flags and conversion specified.
39     *
40     * @param f
41     *           the flags.
42     * @param c
43     *           the conversion.
44     */
45    public FormatFlagsConversionMismatchException(String f, char c) {
46        if (null == f) {
47            throw new NullPointerException();
48        }
49        this.f = f;
50        this.c = c;
51    }
52
53    /**
54     * Returns the incompatible format flag.
55     *
56     * @return the incompatible format flag.
57     */
58    public String getFlags() {
59        return f;
60    }
61
62    /**
63     * Returns the incompatible conversion.
64     *
65     * @return the incompatible conversion.
66     */
67    public char getConversion() {
68        return c;
69    }
70
71    /**
72     * Returns the message string of the {@code FormatFlagsConversionMismatchException}.
73     *
74     * @return the message string of the {@code FormatFlagsConversionMismatchException}.
75     */
76    @Override
77    public String getMessage() {
78        StringBuilder buffer = new StringBuilder();
79        buffer.append("Mismatched Convertor =");
80        buffer.append(c);
81        buffer.append(", Flags= ");
82        buffer.append(f);
83        return buffer.toString();
84    }
85}
86