public class GlobalUtilities
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
GlobalUtilities.ComponentSizeGuardian
To keep a minimum size for a
Component |
static class |
GlobalUtilities.GUI |
Modifier and Type | Field and Description |
---|---|
static AFDateFormat |
c_afDateFormat |
static java.text.DecimalFormat |
c_decimalFormat |
static java.text.NumberFormat |
c_defaultCurrencyFormat |
static java.text.NumberFormat |
c_defaultDecimalFormat |
static java.util.Locale |
c_defaultLocale |
static java.text.DateFormat |
c_defaultTWDateFormat |
static java.text.DateFormatSymbols |
c_localizedDateFormatSymbols |
static AFDateFormat.TaiwanDateFormat |
c_twDateFormat |
static boolean |
DEBUG |
static javax.swing.ImageIcon |
defaultImage |
static int |
LOG_MODE_DEFAULT |
static int |
LOG_MODE_NONE |
static int |
LOOP_COUNT_LIMIT |
static java.util.Locale |
m_currentLocale |
static java.util.ResourceBundle |
m_formLabels |
static int |
setEnabled_option_default |
static int |
setEnabled_option_JTableGrayOut |
Constructor and Description |
---|
GlobalUtilities() |
Modifier and Type | Method and Description |
---|---|
static GlobalUtilities.ComponentSizeGuardian |
addComponentSizeGuardian(java.awt.Component c,
int minWidth,
int minHeight) |
static void |
applyComponentOrientation(java.awt.Component jcmp) |
static void |
changeFont(java.awt.Container container,
java.awt.Font font) |
static void |
changeFont(javax.swing.JDialog dlg,
java.awt.Font font) |
static void |
changeMenuFont(javax.swing.MenuElement menuElement,
java.awt.Font font) |
static void |
copyFile(java.io.File srcFile,
java.io.File dstFile) |
static java.util.ResourceBundle |
getBundle(java.lang.String bundleNamePrefix) |
static java.util.ResourceBundle |
getBundle(java.lang.String bundleNamePrefix,
java.util.Locale locale) |
static java.lang.Object |
getClipContent() |
static java.lang.Object |
getClipOwner() |
static java.lang.String |
getCurrentTime() |
static javax.swing.ImageIcon |
getImage(java.lang.Class baseClass,
java.lang.String gifFile) |
static javax.swing.ImageIcon |
getImage(java.lang.String imagePath) |
static java.util.Locale |
getLocale() |
static java.util.PropertyResourceBundle |
getPropertyResourceBundle(java.lang.String name) |
static java.lang.String |
getString(java.lang.String key) |
static void |
hardCenter(java.awt.Component C) |
static boolean |
isLeftToRight() |
static java.util.Locale |
parseLocale(java.lang.String localeString) |
static void |
reportError(java.lang.String errorMsg,
java.lang.Exception ex)
Reports the error.
|
static void |
setClipBoard(java.lang.Object content,
java.lang.Object owner) |
static void |
setComponentFocus(javax.swing.JComponent cmp) |
static void |
setContainerColor(java.awt.Container container,
java.awt.Color color) |
static void |
setEnabledRecursively(java.awt.Component comp,
boolean b) |
static void |
setEnabledRecursively(java.awt.Component comp,
boolean enabled,
int option) |
static void |
setLanguage(java.lang.String lang) |
static void |
setLocale(java.util.Locale locale) |
static void |
setMenuColor(javax.swing.MenuElement menuElement,
java.awt.Color color) |
static void |
showMemoryUsage() |
static byte[] |
simpleCipherDecrypt(byte[] b) |
static java.lang.String |
simpleCipherDecryptWithBase64(java.lang.String s,
java.lang.String nameOfTheItem)
Gets the the original string from the string result of
simpleCipherEncryptWithBase64(..) |
static java.lang.String |
simpleCipherDecryptWithBase64(java.lang.String s,
java.lang.String messageForException,
int logMode,
boolean isToReturnInputIfBase64NotDecoded)
Gets the the original string from the result of
simpleCipherEncryptWithBase64(..) |
static byte[] |
simpleCipherEncrypt(byte[] b) |
static java.lang.String |
simpleCipherEncryptWithBase64(java.lang.String s)
Encrypts a string by a specific simple way, and then return it encoded with Base64.
|
static void |
softCenter(java.awt.Component S,
java.awt.Component C) |
public static final boolean DEBUG
public static final java.util.Locale c_defaultLocale
public static java.util.Locale m_currentLocale
public static java.util.ResourceBundle m_formLabels
public static java.text.DecimalFormat c_decimalFormat
public static java.text.NumberFormat c_defaultDecimalFormat
public static java.text.NumberFormat c_defaultCurrencyFormat
public static java.text.DateFormatSymbols c_localizedDateFormatSymbols
public static AFDateFormat c_afDateFormat
public static AFDateFormat.TaiwanDateFormat c_twDateFormat
public static java.text.DateFormat c_defaultTWDateFormat
public static javax.swing.ImageIcon defaultImage
public static final int setEnabled_option_default
public static final int setEnabled_option_JTableGrayOut
public static final int LOOP_COUNT_LIMIT
public static final int LOG_MODE_NONE
public static final int LOG_MODE_DEFAULT
public static void setLanguage(java.lang.String lang)
lang
- String - locale name; null
will be interpretted as the JVM default localepublic static java.util.Locale parseLocale(java.lang.String localeString)
public static java.util.Locale getLocale()
public static void setLocale(java.util.Locale locale)
public static java.util.ResourceBundle getBundle(java.lang.String bundleNamePrefix)
public static java.util.ResourceBundle getBundle(java.lang.String bundleNamePrefix, java.util.Locale locale)
public static java.lang.String getString(java.lang.String key)
public static java.util.PropertyResourceBundle getPropertyResourceBundle(java.lang.String name)
public static javax.swing.ImageIcon getImage(java.lang.String imagePath)
public static javax.swing.ImageIcon getImage(java.lang.Class baseClass, java.lang.String gifFile)
public static void hardCenter(java.awt.Component C)
public static void softCenter(java.awt.Component S, java.awt.Component C)
public static GlobalUtilities.ComponentSizeGuardian addComponentSizeGuardian(java.awt.Component c, int minWidth, int minHeight)
public static void changeFont(java.awt.Container container, java.awt.Font font)
public static void changeFont(javax.swing.JDialog dlg, java.awt.Font font)
public static void changeMenuFont(javax.swing.MenuElement menuElement, java.awt.Font font)
public static void setMenuColor(javax.swing.MenuElement menuElement, java.awt.Color color)
public static void setContainerColor(java.awt.Container container, java.awt.Color color)
public static final void setEnabledRecursively(java.awt.Component comp, boolean b)
public static void setEnabledRecursively(java.awt.Component comp, boolean enabled, int option)
public static void copyFile(java.io.File srcFile, java.io.File dstFile) throws java.io.IOException
java.io.IOException
public static void showMemoryUsage()
public static final byte[] simpleCipherEncrypt(byte[] b) throws java.lang.Exception
java.lang.Exception
public static final byte[] simpleCipherDecrypt(byte[] b) throws java.lang.Exception
java.lang.Exception
public static java.lang.String simpleCipherEncryptWithBase64(java.lang.String s)
s
- String the original string. (s.length >= 0) must be true.public static java.lang.String simpleCipherDecryptWithBase64(java.lang.String s, java.lang.String nameOfTheItem)
simpleCipherEncryptWithBase64(..)
,
with some exception handling/reporting extensions.
It's a specific usage of simpleCipherDecryptWithBase64(String, String)
,
suitable for most cases for a password property stored in a .properties file;
In this usage the backward-compatibility for a password property
(stored as plain text in older versions and as Encypted/Encoded string in newer ones)
is achieved for it will return the exact string as the input if it's not Base64-encoded.public static java.lang.String simpleCipherDecryptWithBase64(java.lang.String s, java.lang.String messageForException, int logMode, boolean isToReturnInputIfBase64NotDecoded)
simpleCipherEncryptWithBase64(..)
,
with some exception handling/reporting extensions.
Examples:
simpleCipherDecryptWithBase64(anUserPasswordStoredWhichIsNotEncryptedAndEncoded, "Oh My God!\nThe property 'UserPassword'", LOG_MODE_DEFAULT, true); will produce a message reporting exception as follows: Oh My God! The property 'userPasswordStored' can't be decoded by Base64, use its original value
s
- String (A) the result of the original string encrypted by simpleCipherEncrypt
,
and then encoded with Base64; (s.length > 0) must be true.
(B) ""(empty string)
(C) a string which is not encrypted in simpleCipherEncrypt
,
and then encoded with Base64; (s.length > 0) must be true.
(D) none of above (non-empty and not encoded with Base64)nameOfTheItem
- the name of the item being decrypted, it's to be inserted in the front of the exception warning message
to aware the user which string is unable to be decrypted - if it's not null
...;
"The-string-being-decrypted" is used if it's null
.logMode
- LOG_MODE_NONE
to cause it to produce no warning message;
LOG_MODE_DEFAULT
to cause it to warn about
(B),(C),(D) cases, and print the stack trace for any exception during the Cipher
invocation.isToReturnInputIfBase64NotDecoded
is true
...
In this option the backward-compatibility for a password property
(stored as plain text in older versions and as Encypted/Encoded string in newer ones)
is achieved for it will return the exact string as the input if it's not Base64-encoded.
same as (B) otherwise;
(C) same as (D) (sometimes the un-encoded plain text can be decoded by Base64,
so we probably need (C) be the same as (D))public static void reportError(java.lang.String errorMsg, java.lang.Exception ex)
errorMsg
- ok to be null
.ex
- the Exception
to be print stack trace of.public static java.lang.String getCurrentTime()
public static void setComponentFocus(javax.swing.JComponent cmp)
public static void applyComponentOrientation(java.awt.Component jcmp)
public static java.lang.Object getClipContent()
public static java.lang.Object getClipOwner()
public static void setClipBoard(java.lang.Object content, java.lang.Object owner)
public static boolean isLeftToRight()