|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectpl.gda.pg.eti.ask.przemyslawbielicki.aeh.translation.ExceptionTranslator
ExceptionTranslator is a singleton class. That means that
only one instance of this class can exist.
ExceptionTranslator translates exception given by user to resource
path (if translation exists). User that want to retrieve exception translation
can automatically add translation for unexistent exception to XML database.
XML database is automatically loaded and saved from and to filesystem.
TODO convert to EJB class
| Field Summary | |
private static String |
databasePath_
Path where XML database is stored - file name |
private Hashtable |
exceptionTranslations_
Table containing translations for concrete classes. |
private static ExceptionTranslator |
exceptionTranslator_
Instance of singleton class. |
private static boolean |
initialized_
Indicates if object is initialized_ or not. |
| Constructor Summary | |
private |
ExceptionTranslator()
Constructor is private to prevent calling it by anyone. |
| Method Summary | |
private String |
addDefaultTranslation(Throwable throwable)
Adds default translation for given exception. |
void |
addExceptionTranslation(ExceptionTranslation translation)
Adds default translation for given exception. |
boolean |
deserializeTranslations(String fileName)
Deserializes translation XML database from file fileName to objects form.
|
static ExceptionTranslator |
getInstance()
Typical getInstance method. |
String |
getTranslation(Throwable throwable)
Retrieves translation resource path for given exception. |
String |
getTranslation(Throwable throwable,
boolean addDefault)
Retrieves translation resource path for given exception. |
boolean |
serializeTranslations(String fileName)
Serializes translation XML database from objects form to file fileName.
|
static void |
setDatabasePath(String path)
Setter method for XML database |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private Hashtable exceptionTranslations_
ExceptionTranslation.exceptionClass_.
private static boolean initialized_
private static ExceptionTranslator exceptionTranslator_
private static String databasePath_
| Constructor Detail |
private ExceptionTranslator()
| Method Detail |
public static ExceptionTranslator getInstance()
getInstance method. If object is not initialized_
this method runs private constructor ExceptionTranslator()
and creates a singleton instance.
ExceptionTranslator instancepublic static void setDatabasePath(String path)
path - to XML database
public String getTranslation(Throwable throwable)
throws TranslationNotFoundException,
ResourceNotDefinedException
throwable - exception to translate
TranslationNotFoundException - translation for given exception doesn't exist
ResourceNotDefinedException - translation for given exception exists but
resource path is not defined
public String getTranslation(Throwable throwable,
boolean addDefault)
throws TranslationNotFoundException,
ResourceNotDefinedException
addDefault argument is set to
true default translation for given exception is added to XML structure.
If addDefault argument is set to false this method is equal
getTranslation(Throwable)
throwable - exception to translate
TranslationNotFoundException - translation for given exception doesn't exist
ResourceNotDefinedException - translation for given exception exists but
resource path is not definedgetTranslation(Throwable, boolean)private String addDefaultTranslation(Throwable throwable)
throwable class this method adds this class to XML database. Next message
translation is added to database. Please remember that newly added translation for
given exception is not configured in database (in the meaning that its translation
resource is null).
throwable - exception to add default translation for
public void addExceptionTranslation(ExceptionTranslation translation)
throws DuplicateTranslationException
translation
class ExceptionTranslation.exceptionClass_ already exists DuplicateTranslationException
is thrown.
translation - translation to add to XML database
DuplicateTranslationException - is thrown when translation for given class already existspublic boolean deserializeTranslations(String fileName)
fileName to objects form.
Simply creates objects structure from XML file.
fileName - path to file where translation XML database is
true when deserializing finishes correctly and false
in other casepublic boolean serializeTranslations(String fileName)
fileName.
Simply creates XML document and then writes it to file.
fileName - path to file where translation XML database is
true when serializing finishes correctly and false
in other case
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||