|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lapetus_ltd.api.common.TLptsCharSetLocaleUtil
public class TLptsCharSetLocaleUtil
Class Description : Provides services for CharSet and locale functionality.
This factory provides the ability to get charset lists and actual charset objects.
Furthermore, it allows for locale functionality and listening. In other words, all classes wishing to be informed of
locale changes need to register as locale listeners ILptsLogListener
using addLocaleListener(ILptsCharSetLocaleListener)
.
$LastChangedRevision: 1191 $
$LastChangedDate:: 2010-11-18 15:53:39#$
Field Summary | |
---|---|
static java.lang.String |
NO_CHARSET_TRANSLATION
Used as the default for CHARSET processing |
Method Summary | |
---|---|
static void |
addLocaleListener(ILptsCharSetLocaleListener listener)
Adds an implementation of the ILptsCharSetLocaleListener interface to be informed of locale changes. |
static java.nio.charset.Charset |
getCharSet(java.lang.String charsetName)
Gets the actual charset by its name(See Charset ). |
static java.util.Set<java.lang.String> |
getCharsetNameList()
Gets a list of all the charset names on the current system. |
static java.util.Locale |
getCurrentLocale()
Gets Current Application Locale. |
static java.lang.String |
getStringWithCharset(byte[] ccsBytes,
java.lang.String charSet)
Returns a string that is encoded with the supplied charset. |
static void |
removeLocaleListener(ILptsCharSetLocaleListener listener)
Remove an implementation of the ILptsCharSetLocaleListener interface from the listener list. |
static boolean |
setLocale(java.lang.String language,
java.lang.String country)
Sets the default system locale to the language and country specified. |
static void |
zI()
Obfuscated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String NO_CHARSET_TRANSLATION
Method Detail |
---|
public static void addLocaleListener(ILptsCharSetLocaleListener listener)
TLptsCharSetLocaleUtil.addLocaleListener(new ILptsCharSetLocaleListener() { public void localeHasChanged(String country, String language) { if (country.equalsIgnoreCase ("de") && language.equalsIgnoreCase("de")) System.out.println("Oops! I don't know any German."); } }
listener
- An implementation of the ILptsCharSetLocaleListener interface.public static java.nio.charset.Charset getCharSet(java.lang.String charsetName)
Charset
).
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Yes
Notes : JComboBox combo = new JComboBox(); DefaultComboBoxModel dlm = new DefaultComboBoxModel(); for (String charset : TLptsCharSetLocaleUtil.getCharsetNameList()) if (!charset.equalsIgnoreCase(TLptsCharSetLocaleUtil.NO_CHARSET_TRANSLATION)) dlm.addElement(charset); combo.setModel(dlm); ... private comboActionPerformed() { Charset charset = TLptsCharSetLocaleUtil.getCharSet(combo.getSelectedItem()); }
charsetName
- The name of the charset. Could be retrieved from getCharsetNameList()
public static java.util.Set<java.lang.String> getCharsetNameList()
JComboBox combo = new JComboBox(); DefaultComboBoxModel dlm = new DefaultComboBoxModel(); for (String charset : TLptsCharSetLocaleUtil.getCharsetNameList()) if (!charset.equalsIgnoreCase(TLptsCharSetLocaleUtil.NO_CHARSET_TRANSLATION)) dlm.addElement(charset); combo.setModel(dlm);
public static java.util.Locale getCurrentLocale()
Locale loc = TLptsCharSetLocaleUtil.getCurrentLocale(); System.out.println(loc.getCountry()); System.out.println(loc.getLanguage()); Result (in our case) :GB en
public static java.lang.String getStringWithCharset(byte[] ccsBytes, java.lang.String charSet)
byte[] firstColumnBytes = rowset.getBytes(1); String uftString = TLptsCharSetLocaleUtil.getStringWithCharset(firstColumnBytes,"UTF-8"); System.out.print("The UTF-8 string for the bytes of column 1 is " + utfString);
ccsBytes
- An array of bytes to be encoded.charSet
- The name of the charset to use for encoding. Could be retrieved from getCharsetNameList()
public static void removeLocaleListener(ILptsCharSetLocaleListener listener)
boolean alwaysReturnsFalse = TLptsCharSetLocaleUtil.removeLocaleListener(new ILptsCharSetLocaleListener() { public void localeHasChanged(String country, String language) { // some code here that will never be executed. } }
listener
- An implementation of the ILptsCharSetLocaleListener interface.public static boolean setLocale(java.lang.String language, java.lang.String country)
A DEBUG log is generated on the successful completion of this function.
Furthermore, all listeners are informed of the locale change, if successful.
Example :boolean doesThisLocaleExist = TLptsCharSetLocaleUtil.setLocale("en","gb"); Result : normally true.
country
- A case insensitive value for the country code (ie : "gb" or "GB" or "Gb" for Great Britain)language
- A case insensitive value for the language code (ie : "en" or ""eN" for English)
public static void zI()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |