OSDN Git Service

Initial commit.
[gamerandomizer/gamerandomizer.git] / GameRandomizer / src / jp / sourceforge / gamerandomizerlib / GameBuilderXMLFileException.java
1 //
2 // Copyright (c) 2013  Motoyuki Kasahara
3 //
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.
8 //
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.
13 //
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/>.
16 //
17 package jp.sourceforge.gamerandomizerlib;
18
19 /**
20  * <p>
21  * Exception class for GameBuilderXMLFile.
22  * </p>
23  *
24  * @author   Motoyuki Kasahara
25  * @version  1.0
26  */
27 public final class GameBuilderXMLFileException extends GameBuilderException {
28         private String fileTitle;
29         private int lineNo;
30         private String message;
31
32         /**
33          * Constructs an object with the specified file title, message format
34          * and its arguments.
35          *
36          * @param  fileTitleArg  a file title
37          * @param  formatArg     a message format
38          * @param  args          arguments to the message format.
39          */
40         public GameBuilderXMLFileException(String fileTitleArg, String formatArg,
41                 Object ... args) {
42                 super();
43
44                 fileTitle = fileTitleArg;
45                 lineNo    = 0;
46                 String header = String.format("%s: ", fileTitleArg);
47                 message = header + String.format(formatArg, args);
48         }
49
50         /**
51          * Constructs an object with the specified file title, line number,
52          * message format and its arguments.
53          *
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.
58          */
59         public GameBuilderXMLFileException(String fileTitleArg, int lineNoArg,
60                 String formatArg, Object ... args) {
61                 super();
62
63                 fileTitle = fileTitleArg;
64                 lineNo    = lineNoArg;
65                 String header = String.format("%s: %d: ", fileTitleArg, lineNo);
66                 message = header + String.format(formatArg, args);
67         }
68
69         /**
70          * Constructs an object with the specified cause, file title, message
71          * format and its arguments.
72          *
73          * @param  causeArg      cause
74          * @param  fileTitleArg  a file title
75          * @param  formatArg     a message format
76          * @param  args          arguments to the message format.
77          */
78         public GameBuilderXMLFileException(Throwable causeArg, 
79                 String fileTitleArg, String formatArg, Object ... args) {
80                 super(causeArg);
81
82                 fileTitle = fileTitleArg;
83                 lineNo    = 0;
84                 String header = String.format("%s: ", fileTitleArg);
85                 message = header + String.format(formatArg, args);
86         }
87
88         /**
89          * Constructs an object with the specified cause, file title, line number,
90          * message format and its arguments.
91          *
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.
97          */
98         public GameBuilderXMLFileException(Throwable causeArg, 
99                 String fileTitleArg, int lineNoArg, String formatArg, 
100                 Object ... args) {
101                 super(causeArg);
102
103                 fileTitle = fileTitleArg;
104                 lineNo    = lineNoArg;
105                 String header = String.format("%s: %d: ", fileTitleArg, lineNo);
106                 message = header + String.format(formatArg, args);
107         }
108
109         /**
110          * Returns a file title (path to a file relative to the top directory).
111          *
112          * @return  a file title
113          */
114         public String getFileTitle() {
115                 return fileTitle;
116         }
117
118         /**
119          * Returns a line number.
120          *
121          * @return  a line number.
122          */
123         public int getLineNo() {
124                 return lineNo;
125         }
126
127         /**
128          * Returns an error message.
129          *
130          * @return  an error message.
131          */
132         @Override
133         public String getMessage() {
134                 return message;
135         }
136
137         /**
138          * Returns a localized error message.
139          *
140          * @return  a localized error message.
141          */
142         @Override
143         public String getLocalizedMessage() {
144                 return message;  // not supported yet.
145         }
146 }