package org.mxchange.jcore;
import java.util.ResourceBundle;
-import java.util.StringTokenizer;
import org.mxchange.jcore.application.Application;
import org.mxchange.jcore.client.Client;
import org.mxchange.jcore.facade.Facade;
protected BaseFrameworkSystem () {
}
- @Override
- public Application getApplication () {
- return this.application;
+ /**
+ * Constructor with a facade
+ * <p>
+ * @param facade Facade instance
+ */
+ protected BaseFrameworkSystem (final Facade facade) {
+ // Invole other constructor
+ this();
+
+ // Check parameter
+ if (null == facade) {
+ // Throw NPE
+ throw new NullPointerException("facade is null"); //NOI18N
+ }
+
+ // Set instance
+ this.facade = facade;
}
@Override
- public Facade getFacade () {
- return this.facade;
+ public Application getApplication () {
+ return this.application;
}
@Override
- public String getMessageStringFromKey (final String key) {
- // Return message
- return this.getBundle().getString(key);
+ public Client getClient () {
+ return this.client;
}
/**
- * Getter for bundle instance
+ * Client instance
* <p>
- * @return Resource bundle
+ * @param client the client to set
*/
- protected ResourceBundle getBundle () {
- return BaseFrameworkSystem.bundle;
+ protected void setClient (final Client client) {
+ this.client = client;
}
/**
- * Setter for bundle instance
+ * Application instance
* <p>
- * @param bundle the bundle to set
+ * @param application the application to set
*/
- protected static void setBundle (final ResourceBundle bundle) {
- BaseFrameworkSystem.bundle = bundle;
+ protected void setApplication (final Application application) {
+ this.application = application;
+ }
+
+ @Override
+ public Facade getFacade () {
+ return this.facade;
}
/**
this.facade = facade;
}
- /**
- * Application instance
- * <p>
- * @param application the application to set
- */
- protected void setApplication (final Application application) {
- this.application = application;
- }
-
@Override
- public Client getClient () {
- return this.client;
+ public String getMessageStringFromKey (final String key) {
+ // Return message
+ return this.getBundle().getString(key);
}
/**
- * Client instance
+ * Getter for bundle instance
* <p>
- * @param client the client to set
+ * @return Resource bundle
*/
- protected void setClient (final Client client) {
- this.client = client;
- }
-
- /**
- * Converts null to empty string or leaves original object untouched.
- * <p>
- * @param object Any string
- * <p>
- * @return Empty string if null or original string
- * @TODO: Move to own utility class
- */
- protected Object convertNullToEmpty (final Object object) {
- // Is it null?
- if (null == object) {
- // Return empty string
- return ""; //NOI18N
- }
-
- // Return it
- return object;
+ protected ResourceBundle getBundle () {
+ return BaseFrameworkSystem.bundle;
}
/**
- * Some "getter" for an array from given string and tokenizer
- * <p>
- * @param str String to tokenize and get array from
- * @param delimiter Delimiter
+ * Setter for bundle instance
* <p>
- * @return Array from tokenized string
- * @TODO: Move to own utility class
+ * @param bundle the bundle to set
*/
- protected String[] getArrayFromString (final String str, final String delimiter) {
- // Get tokenizer
- StringTokenizer tokenizer = new StringTokenizer(str, delimiter);
-
- // Init array and index
- String[] tokens = new String[tokenizer.countTokens()];
- int index = 0;
-
- // Run through all tokens
- while (tokenizer.hasMoreTokens()) {
- // Get current token and add it
- tokens[index] = tokenizer.nextToken();
-
- // Increment index
- index++;
- }
-
- // Return it
- return tokens;
+ protected static void setBundle (final ResourceBundle bundle) {
+ BaseFrameworkSystem.bundle = bundle;
}
/**
--- /dev/null
+/*
+ * Copyright (C) 2022 Roland Häder<roland@mxchange.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcore.utils;
+
+import java.util.StringTokenizer;
+
+/**
+ * An utilities class for this framework
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class FrameworkUtils {
+
+ /**
+ * Converts null to empty string or leaves original object untouched.
+ * <p>
+ * @param object Any string
+ * <p>
+ * @return Empty string if null or original string
+ */
+ public static Object convertNullToEmpty (final Object object) {
+ // Is it null?
+ if (null == object) {
+ // Return empty string
+ return ""; //NOI18N
+ }
+
+ // Return it
+ return object;
+ }
+
+ /**
+ * Some "getter" for an array from given string and tokenizer
+ * <p>
+ * @param str String to tokenize and get array from
+ * @param delimiter Delimiter
+ * <p>
+ * @return Array from tokenized string
+ */
+ public static String[] getArrayFromString (final String str, final String delimiter) {
+ // Get tokenizer
+ StringTokenizer tokenizer = new StringTokenizer(str, delimiter);
+
+ // Init array and index
+ String[] tokens = new String[tokenizer.countTokens()];
+ int index = 0;
+
+ // Run through all tokens
+ while (tokenizer.hasMoreTokens()) {
+ // Get current token and add it
+ tokens[index] = tokenizer.nextToken();
+ // Increment index
+ index++;
+ }
+
+ // Return it
+ return tokens;
+ }
+
+ /**
+ * No instances from utility classes
+ */
+ private FrameworkUtils () {
+ }
+
+}