KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > commons > exception > ExoMessageException


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.commons.exception;
6
7 import java.util.ResourceBundle JavaDoc ;
8 import org.exoplatform.commons.utils.Formater;
9 /*
10  * @author: Tuan Nguyen
11  * @version: $Id: ExoMessageException.java,v 1.2 2004/11/03 01:24:55 tuan08 Exp $
12  * @since: 0.0
13  * @email: tuan08@yahoo.com
14  */

15 public class ExoMessageException extends ExoException {
16   private static Formater ft_ = Formater.getDefaultFormater() ;
17   
18   private String JavaDoc messageKey_ ;
19   private Object JavaDoc[] args_ ;
20   
21   public ExoMessageException(String JavaDoc messageKey) {
22     messageKey_ = messageKey ;
23   }
24   
25   public ExoMessageException(String JavaDoc messageKey, Object JavaDoc[] args) {
26     messageKey_ = messageKey ;
27     args_ = args ;
28   }
29   
30   public String JavaDoc getMessageKey() { return messageKey_ ; }
31   
32   public Object JavaDoc[] getArguments() { return args_ ; }
33   
34   public String JavaDoc getMessage(ResourceBundle JavaDoc res) {
35     if(args_ == null) {
36       return res.getString(messageKey_) ;
37     }
38     return ft_.format(res.getString(messageKey_) , args_) ;
39   }
40   
41   public String JavaDoc getExceptionDescription() {
42     return "Usually, this is not a critical exception. The exception is raised " +
43            "when unexpected condition such wrong input, object not found...." +
44            "The application should not crashed and it should continue working";
45   }
46   
47   public String JavaDoc getErrorCode() { return "EXO ERROR: " ; }
48 }
Popular Tags