pl.gda.pg.eti.ask.przemyslawbielicki.aeh.translation
Class ExceptionTranslation

java.lang.Object
  extended bypl.gda.pg.eti.ask.przemyslawbielicki.aeh.translation.ExceptionTranslation

public class ExceptionTranslation
extends Object

ExceptionTranslation contains translation list for concrete exceptionClass_ in Vector messages_.

ExceptionTranslation contains methods that enable retrieving existing translations from database by finder methods. It also contains methods that enable adding new translations to XML database.

ExceptionTranslation can be converted to XML element Element by getElement(DocumentImpl) method.

Version:
0.9
Author:
Przemyslaw Bielicki
Gdansk University of Technology
Faculty of Electronics, Telecommunication and Computer Science
Distributed Computer Systems

Field Summary
private  String exceptionClass_
          Exception class name
private  HashMap messages_
          List of concrete exception messages_ translations
 
Constructor Summary
ExceptionTranslation()
           
 
Method Summary
 void addMessage(MessageTranslation message)
          Adds new message translation to database.
 MessageTranslation findByLikeMessage(String message)
          Finds message translation with given message.
 MessageTranslation findByMessage(String message)
          Finds message translation with given message.
 ElementImpl getElement(DocumentImpl document)
          Retrieves XML element for current exception translation subtree.
 String getExceptionClass()
          Getter method for exception class name
 void setExceptionClass(String string)
          Setter method for exception class name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

exceptionClass_

private String exceptionClass_
Exception class name


messages_

private HashMap messages_
List of concrete exception messages_ translations

See Also:
MessageTranslation
Constructor Detail

ExceptionTranslation

public ExceptionTranslation()
Method Detail

getElement

public ElementImpl getElement(DocumentImpl document)
Retrieves XML element for current exception translation subtree. This method iterative add all children of this translation element.

Parameters:
document - parent document to add current element to
Returns:
XML document of current translation element

getExceptionClass

public String getExceptionClass()
Getter method for exception class name

Returns:
exception class name

setExceptionClass

public void setExceptionClass(String string)
Setter method for exception class name

Parameters:
string - exception class name

addMessage

public void addMessage(MessageTranslation message)
                throws DuplicateMessageException
Adds new message translation to database. If such a message or message like this already exists in database DuplicateMessageException is thrown.

Parameters:
message - message translation to add to database
Throws:
DuplicateMessageException - is thrown during the attempt to add message translation that already exists in database
See Also:
findByMessage(String), findByLikeMessage(String)

findByMessage

public MessageTranslation findByMessage(String message)
                                 throws TranslationNotFoundException
Finds message translation with given message. This method searchs exception messages_ by name using method String.equals(java.lang.Object).

For example: user is looking for exception that message is Unable to add user. There are two exception messages_ for this class in XML database. First of them has exception message as follows: Unable to add user to database and the second one has exception message: Unable to add user. This method will retrieve second message translation. See findByLikeMessage(String) for other example.

Parameters:
message - to find the message translation with
Returns:
message translation
Throws:
TranslationNotFoundException - is thrown if there is no such message translation in database

findByLikeMessage

public MessageTranslation findByLikeMessage(String message)
                                     throws TranslationNotFoundException
Finds message translation with given message. This method searchs exception messages_ by name using method String.indexOf(java.lang.String) Note that this method will retrieve the first found message translation that message fit to message.

For example: user is looking for exception that message is Unable to add user. There are two exception messages_ for this class in XML database. First of them has exception message as follows: Unable to add user to database and the second one has exception message: Unable to add user. This method will retrieve second message translation.

Read careful this example: user is looking for exception that message is Unable to add user to database. Like in first example there are two exception messages_ for this class in XML database. First of them has exception message as follows: Unable to add user (note that order has changed) and the second one has exception message: Unable to add user to database. This method will retrieve the first message translation instead of second message is more like searching message.

Parameters:
message - to find the message translation with
Returns:
message translation
Throws:
TranslationNotFoundException - is thrown if there is no such message translation in database