root / branches / v2_0_0_prep / extensions / extI18n / src / main / java / org / gvsig / i18n / I18nException.java @ 38564
History | View | Annotate | Download (2.5 KB)
1 | 26048 | cordinyana | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | 31544 | cordinyana | * of the Valencian Government (CIT)
|
5 | 26048 | cordinyana | *
|
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | */
|
||
22 | |||
23 | /*
|
||
24 | * AUTHORS (In addition to CIT):
|
||
25 | * 2009 {DiSiD Technologies} {New extension for installation and update of text translations}
|
||
26 | */
|
||
27 | package org.gvsig.i18n; |
||
28 | |||
29 | 29635 | jpiera | import org.gvsig.andami.messages.NotificationManager; |
30 | 26048 | cordinyana | |
31 | /**
|
||
32 | * Exception for errors of the I18nManager.
|
||
33 | *
|
||
34 | * TODO: hacer que extienda BaseException cuando se pase a gvSIG trunk.
|
||
35 | *
|
||
36 | * @author <a href="mailto:dcervera@disid.com">David Cervera</a>
|
||
37 | */
|
||
38 | public class I18nException extends Exception { |
||
39 | |||
40 | private static final long serialVersionUID = 2877056472517898602L; |
||
41 | |||
42 | private String key; |
||
43 | |||
44 | /**
|
||
45 | * Creates a new exception with an error message.
|
||
46 | *
|
||
47 | * @param message
|
||
48 | * the error message
|
||
49 | * @param key
|
||
50 | * the i18n key to localize the exception message
|
||
51 | */
|
||
52 | public I18nException(String message, String key) { |
||
53 | super(message);
|
||
54 | this.key = key;
|
||
55 | } |
||
56 | |||
57 | /**
|
||
58 | * Creates a new exception with an error message and a cause exception.
|
||
59 | *
|
||
60 | * @param message
|
||
61 | * the error message
|
||
62 | * @param key
|
||
63 | * the i18n key to localize the exception message
|
||
64 | * @param cause
|
||
65 | * the error that caused the exception
|
||
66 | */
|
||
67 | public I18nException(String message, String key, Throwable cause) { |
||
68 | super(message, cause);
|
||
69 | this.key = key;
|
||
70 | } |
||
71 | |||
72 | public String getLocalizedMessage() { |
||
73 | String msg = Messages.getText(key);
|
||
74 | if (msg.equals(key)) {
|
||
75 | msg = getMessage(); |
||
76 | } |
||
77 | return msg;
|
||
78 | } |
||
79 | |||
80 | /**
|
||
81 | * Show the exception error in through the NotificationManager.
|
||
82 | */
|
||
83 | public void showError() { |
||
84 | NotificationManager.addError(getLocalizedMessage(), this);
|
||
85 | } |
||
86 | } |