Coverage Report - org.jtheque.core.managers.error.InternationalizedError
 
Classes in this File Line Coverage Branch Coverage Complexity
InternationalizedError
0 %
0/19
0 %
0/2
1.143
 
 1  
 package org.jtheque.core.managers.error;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jtheque.core.managers.Managers;
 20  
 import org.jtheque.core.managers.language.ILanguageManager;
 21  
 import org.jtheque.utils.StringUtils;
 22  
 
 23  
 /**
 24  
  * An error with its message and details internationalized.
 25  
  *
 26  
  * @author Baptiste Wicht
 27  
  */
 28  
 public final class InternationalizedError extends JThequeError {
 29  
     private Object[] messageReplaces;
 30  
     private Object[] detailsReplaces;
 31  
 
 32  
     /**
 33  
      * Construct a new InternationalizedError.
 34  
      *
 35  
      * @param message The message key.
 36  
      */
 37  
     public InternationalizedError(String message) {
 38  0
         super(message);
 39  0
     }
 40  
 
 41  
     /**
 42  
      * Construct a new InternationalizedError.
 43  
      *
 44  
      * @param message  The message key.
 45  
      * @param replaces The replaces for the internationalization variable arguments of the message.
 46  
      */
 47  
     public InternationalizedError(String message, Object... replaces) {
 48  0
         super(message);
 49  
 
 50  0
         messageReplaces = replaces.clone();
 51  0
     }
 52  
 
 53  
     /**
 54  
      * Construct a new InternationalizedError.
 55  
      *
 56  
      * @param message The message key.
 57  
      * @param details The details key.
 58  
      */
 59  
     public InternationalizedError(String message, String details) {
 60  0
         super(message, details);
 61  0
     }
 62  
 
 63  
     /**
 64  
      * Construct a new InternationalizedError.
 65  
      *
 66  
      * @param message  The message key.
 67  
      * @param replaces The replaces for the internationalization variable arguments of the message.
 68  
      * @param details  The details key.
 69  
      */
 70  
     public InternationalizedError(String message, Object[] replaces, String details) {
 71  0
         super(message, details);
 72  
 
 73  0
         messageReplaces = replaces.clone();
 74  0
     }
 75  
 
 76  
     /**
 77  
      * Construct a new InternationalizedError.
 78  
      *
 79  
      * @param message         The message key.
 80  
      * @param replaces        The replaces for the internationalization variable arguments of the message.
 81  
      * @param details         The details key.
 82  
      * @param replacesDetails The replaces for the internationalization variable arguments of the details.
 83  
      */
 84  
     public InternationalizedError(String message, Object[] replaces, String details, Object[] replacesDetails) {
 85  0
         super(message, details);
 86  
 
 87  0
         messageReplaces = replaces.clone();
 88  0
         detailsReplaces = replacesDetails.clone();
 89  0
     }
 90  
 
 91  
     @Override
 92  
     public String getDetails() {
 93  0
         String details = null;
 94  
 
 95  0
         if (!StringUtils.isEmpty(super.getDetails())) {
 96  0
             details = Managers.getManager(ILanguageManager.class).getMessage(super.getDetails(), detailsReplaces);
 97  
         }
 98  
 
 99  0
         return details;
 100  
     }
 101  
 
 102  
     @Override
 103  
     public String getMessage() {
 104  0
         return Managers.getManager(ILanguageManager.class).getMessage(super.getMessage(), messageReplaces);
 105  
     }
 106  
 }