1 package org.tigris.scarab.util; 2 3 48 49 import org.apache.turbine.TurbineException; 51 import org.tigris.scarab.tools.ScarabLocalizationTool; 52 import org.tigris.scarab.tools.localization.L10NMessage; 53 import org.tigris.scarab.tools.localization.LocalizationKey; 54 import org.tigris.scarab.tools.localization.Localizable; 55 56 66 public class ScarabException extends TurbineException implements Localizable 67 { 68 72 Localizable l10nMessage; 73 74 75 80 public ScarabException(LocalizationKey theKey) 81 { 82 l10nMessage = new L10NMessage(theKey); 83 } 84 85 91 public ScarabException(LocalizationKey theKey, Throwable nested) 92 { 93 super(nested); 94 l10nMessage = new L10NMessage(theKey, nested); 95 } 96 97 98 103 public ScarabException(Localizable theL10nInstance) 104 { 105 l10nMessage = theL10nInstance; 106 } 107 108 114 public ScarabException(Localizable theL10nInstance, Throwable nested) 115 { 116 super(nested); 117 l10nMessage = theL10nInstance; 118 } 119 120 121 127 public ScarabException (LocalizationKey theKey, Object [] theParams) 128 { 129 l10nMessage = new L10NMessage(theKey, theParams); 130 } 131 132 138 public ScarabException (LocalizationKey theKey, Object p1) 139 { 140 this(theKey, new Object [] {p1}); 141 } 142 143 150 public ScarabException (LocalizationKey theKey, Object p1, Object p2) 151 { 152 this(theKey, new Object [] {p1, p2}); 153 } 154 155 163 public ScarabException (LocalizationKey theKey, Object p1, Object p2, Object p3) 164 { 165 this(theKey, new Object [] {p1, p2, p3}); 166 } 167 168 169 177 public ScarabException (LocalizationKey theKey, Throwable nested, Object [] theParams) 178 { 179 this(new L10NMessage(theKey, theParams),nested); 180 } 181 182 189 public ScarabException (LocalizationKey theKey, Throwable nested, Object p1) 190 { 191 this(new L10NMessage(theKey, p1),nested); 192 } 193 194 202 public ScarabException (LocalizationKey theKey, Throwable nested, Object p1, Object p2) 203 { 204 this(new L10NMessage(theKey, p1, p2),nested); 205 } 206 207 216 public ScarabException (LocalizationKey theKey, Throwable nested, Object p1, Object p2, Object p3) 217 { 218 this(new L10NMessage(theKey, p1, p2, p3),nested); 219 } 220 221 225 public Localizable getL10nMessage() 226 { 227 return l10nMessage; 228 } 229 230 238 public String getMessage(ScarabLocalizationTool l10n) 239 { 240 String result; 241 if (l10nMessage == null) 242 { 243 result = super.getMessage(); 244 } 245 else 246 { 247 result = l10nMessage.getMessage(l10n); 248 } 249 return result; 250 } 251 252 266 public String getMessage() 267 { 268 String result; 269 if (l10nMessage == null) 270 { 271 result = super.getMessage(); 272 } 273 else 274 { 275 result = l10nMessage.toString(); 276 } 277 return result; 278 } 279 280 } 281 | Popular Tags |