org.shaker.dwu
Class ToolBox

java.lang.Object
  |
  +--org.shaker.dwu.ToolBox

final class ToolBox
extends java.lang.Object

This class contains different useful static methods.

Author:
Philipp Bartsch (codeshaker@gmx.net), GPL License

Field Summary
(package private) static java.io.File DWU_DIR
          File representation of DWU`s path.
(package private) static java.lang.String DWU_PATH
          DWU`s output folder, located in ~/.docwhatsup
private static java.lang.String FILE_SEP
          OS depended path separator
private static java.util.ResourceBundle lang
          Localization ressources
(package private) static java.io.File LOG_FILE
           
 
Constructor Summary
private ToolBox()
          Invisible constructor.
 
Method Summary
(package private) static void checkUp()
          This method create the settings folder and ships generic, default settings at the very first startup.
(package private) static boolean existsLogFile()
          Returns true, if there`s an existing log file in the dwu folder.
(package private) static java.lang.String getLogText()
          Returns the content of the logfile or an empty string, if not existing.
(package private) static java.lang.String[] getSortetSysPropArray()
          Returns a alphabetically (key-) sorted array of system properties.
(package private) static void killLogFile()
          Deletes the local dwu logfile.
(package private) static java.lang.String localize(java.lang.String key)
          Localizes a given dictionary key into a readable string.
(package private) static void logException(java.lang.Exception exception)
          Logs a string in a DWU`s LogFile ($DWU_PATH/error.log).
(package private) static void setLocale(java.util.Locale locale)
          Sets a new Locale and creates a new ResourceBundle.
(package private) static void setSmartSize(java.awt.Window window, int width, int height)
          Sets the size of a window and centers it on screen.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

FILE_SEP

private static final java.lang.String FILE_SEP
OS depended path separator

DWU_PATH

static final java.lang.String DWU_PATH
DWU`s output folder, located in ~/.docwhatsup

DWU_DIR

static final java.io.File DWU_DIR
File representation of DWU`s path.

LOG_FILE

static final java.io.File LOG_FILE

lang

private static java.util.ResourceBundle lang
Localization ressources
Constructor Detail

ToolBox

private ToolBox()
Invisible constructor. This class is not meant to be instantiated.
Method Detail

checkUp

static void checkUp()
This method create the settings folder and ships generic, default settings at the very first startup.

logException

static void logException(java.lang.Exception exception)
Logs a string in a DWU`s LogFile ($DWU_PATH/error.log). This method is used to log internal errors.
Parameters:
exception - the exception object
See Also:
if you want to know, where DWU_PATH is located

existsLogFile

static boolean existsLogFile()
Returns true, if there`s an existing log file in the dwu folder.
Returns:
logfile existence flag

getLogText

static java.lang.String getLogText()
Returns the content of the logfile or an empty string, if not existing.
Returns:
logged text or an empty string, if missing

killLogFile

static void killLogFile()
Deletes the local dwu logfile.

getSortetSysPropArray

static java.lang.String[] getSortetSysPropArray()
Returns a alphabetically (key-) sorted array of system properties.
Returns:
String[] the sorted System Properties String array

setLocale

static void setLocale(java.util.Locale locale)
Sets a new Locale and creates a new ResourceBundle.
Parameters:
locale - the new locale

localize

static java.lang.String localize(java.lang.String key)
Localizes a given dictionary key into a readable string. If the key is unknown, it will be returned!
Parameters:
key - a dictionary key
Returns:
String a localized string or, if unknown, the key

setSmartSize

static void setSmartSize(java.awt.Window window,
                         int width,
                         int height)
Sets the size of a window and centers it on screen.
Parameters:
window - the window object (a dialog, frame ...)
width - the preferred width
height - the preferred height