2 // Copyright (c) 2013 Motoyuki Kasahara
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package jp.sourceforge.gamerandomizerlib;
21 * Exception class for GameBuilderXMLFile.
24 * @author Motoyuki Kasahara
27 public final class GameBuilderXMLFileException extends GameBuilderException {
28 private String fileTitle;
30 private String message;
33 * Constructs an object with the specified file title, message format
36 * @param fileTitleArg a file title
37 * @param formatArg a message format
38 * @param args arguments to the message format.
40 public GameBuilderXMLFileException(String fileTitleArg, String formatArg,
44 fileTitle = fileTitleArg;
46 String header = String.format("%s: ", fileTitleArg);
47 message = header + String.format(formatArg, args);
51 * Constructs an object with the specified file title, line number,
52 * message format and its arguments.
54 * @param fileTitleArg a file title
55 * @param lineNoArg a line number
56 * @param formatArg a message format
57 * @param args arguments to the message format.
59 public GameBuilderXMLFileException(String fileTitleArg, int lineNoArg,
60 String formatArg, Object ... args) {
63 fileTitle = fileTitleArg;
65 String header = String.format("%s: %d: ", fileTitleArg, lineNo);
66 message = header + String.format(formatArg, args);
70 * Constructs an object with the specified cause, file title, message
71 * format and its arguments.
73 * @param causeArg cause
74 * @param fileTitleArg a file title
75 * @param formatArg a message format
76 * @param args arguments to the message format.
78 public GameBuilderXMLFileException(Throwable causeArg,
79 String fileTitleArg, String formatArg, Object ... args) {
82 fileTitle = fileTitleArg;
84 String header = String.format("%s: ", fileTitleArg);
85 message = header + String.format(formatArg, args);
89 * Constructs an object with the specified cause, file title, line number,
90 * message format and its arguments.
92 * @param causeArg cause
93 * @param fileTitleArg a file title
94 * @param lineNoArg a line number
95 * @param formatArg a message format
96 * @param args arguments to the message format.
98 public GameBuilderXMLFileException(Throwable causeArg,
99 String fileTitleArg, int lineNoArg, String formatArg,
103 fileTitle = fileTitleArg;
105 String header = String.format("%s: %d: ", fileTitleArg, lineNo);
106 message = header + String.format(formatArg, args);
110 * Returns a file title (path to a file relative to the top directory).
112 * @return a file title
114 public String getFileTitle() {
119 * Returns a line number.
121 * @return a line number.
123 public int getLineNo() {
128 * Returns an error message.
130 * @return an error message.
133 public String getMessage() {
138 * Returns a localized error message.
140 * @return a localized error message.
143 public String getLocalizedMessage() {
144 return message; // not supported yet.