*/
package org.mxchange.jcore;
-import java.text.MessageFormat;
-import java.util.Arrays;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import org.mxchange.jcore.application.Application;
import org.mxchange.jcore.client.Client;
import org.mxchange.jcore.manager.Manageable;
*/
private static FrameworkInterface selfInstance;
- /**
- * Class' logger
- */
- private final Logger LOG;
-
/**
* Application instance
*/
* Initialize object
*/
{
- // Init logger
- this.LOG = LogManager.getLogger(this);
-
// Need to set it here
selfInstance = this;
}
return this.client;
}
- @Override
- public void logException (final Throwable exception) {
- // Log this exception
- this.getLogger().catching(exception);
- }
-
/**
* Converts null to empty string or leaves original object untouched.
* <p>
* class
*/
protected Object convertNullToEmpty (final Object object) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("object={0}", object)); //NOI18N
-
// Is it null?
if (null == object) {
// Return empty string
return ""; //NOI18N
}
- // Trace message
- this.getLogger().trace(MessageFormat.format("object={0} - EXIT!", object)); //NOI18N
-
// Return it
return object;
}
* Move to own utility class
*/
protected String[] getArrayFromString (final String str, final String delimiter) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("str={0},delimiter={1} - CALLED!", str, delimiter)); //NOI18N
-
// Get tokenizer
StringTokenizer tokenizer = new StringTokenizer(str, delimiter);
// Get current token and add it
tokens[index] = tokenizer.nextToken();
- // Debug message
- this.getLogger().debug(MessageFormat.format("Token at index{0}: {1}", index, tokens[1])); //NOI18N
-
// Increment index
index++;
}
- // Trace message
- this.getLogger().trace(MessageFormat.format("tokens({0})={1} - EXIT!", tokens.length, Arrays.toString(tokens))); //NOI18N
-
// Return it
return tokens;
}
return this.getBundle().getString(key);
}
- /**
- * Aborts program with given exception
- * <p>
- * @param throwable Any type of Throwable
- */
- protected void abortProgramWithException (final Throwable throwable) {
- // Log exception ...
- this.logException(throwable);
-
- // .. and exit
- System.exit(1);
- }
-
/**
* Getter for bundle instance
* <p>
BaseFrameworkSystem.bundle = bundle;
}
- /**
- * Getter for logger instance
- * <p>
- * @return Logger instance
- */
- protected Logger getLogger () {
- return this.LOG;
- }
-
/**
* Initializes i18n bundles
*/
protected void initBundle () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
// Is the bundle set?
if (BaseFrameworkSystem.isBundledInitialized()) {
// Is already set
// Set instance
setBundle(ResourceBundle.getBundle(FrameworkInterface.I18N_BUNDLE_FILE)); // NOI18N
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
}
/**