]> git.mxchange.org Git - jcore-utils.git/blob - src/org/mxchange/jcoreee/BaseEeSystem.java
84ec71ac43f36dace158ea855110da83f0a50ab4
[jcore-utils.git] / src / org / mxchange / jcoreee / BaseEeSystem.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jcoreee;
18
19 import java.io.Serializable;
20 import java.util.ResourceBundle;
21
22 /**
23  * A general class for Java EE applications. You should not include this in your
24  * web applications as this requires that the bundle has to be placed here.
25  *
26  * @author Roland Haeder<roland@mxchange.org>
27  */
28 public abstract class BaseEeSystem implements Serializable {
29
30         /**
31          * Serial number
32          */
33         private static final long serialVersionUID = 48_475_834_783_473_187L;
34
35         /**
36          * Bundle instance
37          */
38         private final ResourceBundle bundle;
39
40         /**
41          * Protectd constructor
42          */
43         protected BaseEeSystem () {
44                 // Load resource bundle
45                 this.bundle = ResourceBundle.getBundle("org/mxchange/localization/bundle");
46         }
47
48         /**
49          * Getter for bundle instance
50          *
51          * @return Bundle instance
52          */
53         protected ResourceBundle getBundle () {
54                 return this.bundle;
55         }
56
57         /**
58          * Getter for message from given key
59          *
60          * @param key Key to get message from
61          * @return Message
62          */
63         protected String getMessageStringFromKey (final String key) {
64                 // Is the bundle loaded?
65                 if (this.getBundle() == null) {
66                         // Abort here
67                         throw new NullPointerException("bundle is null"); //NOI18N
68                 }
69
70                 // Return message
71                 return this.getBundle().getString(key);
72         }
73 }