|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opengts.util.I18N
public class I18N
A set of tools for creating i18n compliant code and providing localized text
Nested Class Summary | |
---|---|
static class |
I18N.Text
Class used to provide lazy localization |
Field Summary | |
---|---|
static java.lang.String |
_LOCAL_STRINGS
|
protected static java.lang.String |
I18N_KEY_END
|
protected static java.lang.String |
I18N_KEY_STARTC
|
protected static java.lang.String |
I18N_KEY_STARTE
|
static java.lang.String |
LOCAL_STRINGS
|
Method Summary | |
---|---|
static I18N.Text |
_getString(java.lang.Class clazz,
java.lang.String key,
java.lang.String dft)
Returns an I18N.Text instance used for lazy localization |
protected static java.lang.String |
decodeNewLine(java.lang.String s)
Converts "\\n" patterns into literal newlines (\n) |
protected static java.lang.StringBuffer |
decodeNewLine(java.lang.StringBuffer s)
Converts "\\n" patterns into literal newlines (\n) |
static java.util.Locale |
getDefaultLocale()
Gets the System default Locale |
static I18N |
getI18N(java.lang.Class pkgClz,
java.util.Locale loc)
Returns an I18N instance based on the specified package name and Locale |
static I18N |
getI18N(java.lang.Package pkg,
java.util.Locale loc)
Returns an I18N instance based on the specified package name and Locale |
static I18N |
getI18N(java.lang.String pkgName,
java.util.Locale loc)
Returns an I18N instance based on the specified package name and Locale |
java.util.Enumeration |
getKeys()
Gets an Enumeration of the LocalString keys for this I18N instance |
java.util.Locale |
getLocale()
gets the Locale for this I18N instance |
static java.util.Locale |
getLocale(java.util.Locale loc)
Returns the specified Locale, or the default Locale if the specified Locale is null |
static java.util.Locale |
getLocale(java.lang.String loc)
Gets the Java Locale instance based on the specified locale name |
static java.util.Locale |
getLocale(java.lang.String loc,
java.util.Locale dft)
Gets the Java Locale instance based on the specified locale name |
static I18N.Text |
getString(java.lang.Class clazz,
java.lang.String key,
java.lang.String dft)
Returns an I18N.Text instance used for lazy localization |
java.lang.String |
getString(java.lang.String key,
java.lang.String dft)
Gets the Localized value for the specified key. |
java.lang.String |
getString(java.lang.String key,
java.lang.String dft,
java.lang.Object arg)
Gets the Localized value for the specified key. |
java.lang.String |
getString(java.lang.String key,
java.lang.String dft,
java.lang.Object[] args)
Gets the Localized value for the specified key. |
java.lang.String |
getString(java.lang.String key,
java.lang.String dft,
java.lang.Object arg0,
java.lang.Object arg1)
Gets the Localized value for the specified key. |
java.lang.String |
getString(java.lang.String key,
java.lang.String dft,
java.lang.Object arg0,
java.lang.Object arg1,
java.lang.Object arg2)
Gets the Localized value for the specified key. |
java.lang.String |
getString(java.lang.String key,
java.lang.String dft,
java.lang.Object arg0,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3)
Gets the Localized value for the specified key. |
static void |
main(java.lang.String[] argv)
Debug/Testing entry point |
protected static java.lang.Object |
NonNull(java.lang.Object obj)
Returns the specified Object, or an empty String if the specified Object is null |
static I18N.Text |
parseText(java.lang.String pkg,
java.lang.String key,
java.lang.String dft)
Returns an I18N.Text instance used for lazy localization. (use in XML loaders to avoid expression matches when auto-updating 'LocalStrings_XX.properties') |
static I18N.Text |
parseText(java.lang.String pkg,
java.lang.String key,
java.lang.String dft,
boolean showError)
Returns an I18N.Text instance used for lazy localization. (use in XML loaders to avoid expression matches when auto-updating 'LocalStrings_XX.properties') |
void |
printKeyValues()
Prints all LocalString keys for this I18N instance |
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 LOCAL_STRINGS
public static final java.lang.String _LOCAL_STRINGS
protected static final java.lang.String I18N_KEY_STARTE
protected static final java.lang.String I18N_KEY_STARTC
protected static final java.lang.String I18N_KEY_END
Method Detail |
---|
public static I18N getI18N(java.lang.Class pkgClz, java.util.Locale loc)
pkgClz
- The class from which the class package is derivedloc
- The Locale resource from with the localized text is loadedpublic static I18N getI18N(java.lang.Package pkg, java.util.Locale loc)
pkg
- The resource packageloc
- The Locale resource from with the localized text is loadedpublic static I18N getI18N(java.lang.String pkgName, java.util.Locale loc)
pkgName
- The resource package nameloc
- The Locale resource from with the localized text is loadedpublic static java.util.Locale getLocale(java.lang.String loc)
loc
- The name of the Locale
public static java.util.Locale getLocale(java.lang.String loc, java.util.Locale dft)
loc
- The name of the Localedft
- The default Locale returned
public static java.util.Locale getLocale(java.util.Locale loc)
loc
- The default Locale
public static java.util.Locale getDefaultLocale()
public java.util.Locale getLocale()
public java.util.Enumeration getKeys()
public void printKeyValues()
public java.lang.String getString(java.lang.String key, java.lang.String dft)
key
- The LocalStrings keydft
- The default String text to return if the LocalStrings key does not exist
public java.lang.String getString(java.lang.String key, java.lang.String dft, java.lang.Object[] args)
key
- The LocalStrings keydft
- The default String text to return if the LocalStrings key does not existargs
- An array of replacement fields
public java.lang.String getString(java.lang.String key, java.lang.String dft, java.lang.Object arg)
key
- The LocalStrings keydft
- The default String text to return if the LocalStrings key does not existarg
- A single replacement field
public java.lang.String getString(java.lang.String key, java.lang.String dft, java.lang.Object arg0, java.lang.Object arg1)
key
- The LocalStrings keydft
- The default String text to return if the LocalStrings key does not existarg0
- The first replacement fieldarg1
- The second replacement field
public java.lang.String getString(java.lang.String key, java.lang.String dft, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)
key
- The LocalStrings keydft
- The default String text to return if the LocalStrings key does not existarg0
- The first replacement fieldarg1
- The second replacement fieldarg2
- The third replacement field
public java.lang.String getString(java.lang.String key, java.lang.String dft, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
key
- The LocalStrings keydft
- The default String text to return if the LocalStrings key does not existarg0
- The first replacement fieldarg1
- The second replacement fieldarg2
- The third replacement fieldarg3
- The forth replacement field
protected static java.lang.Object NonNull(java.lang.Object obj)
obj
- The Object to return
protected static java.lang.String decodeNewLine(java.lang.String s)
s
- The String to convert "\\n" to "\n"
protected static java.lang.StringBuffer decodeNewLine(java.lang.StringBuffer s)
s
- The StringBuffer to convert "\\n" to "\n"
public static I18N.Text parseText(java.lang.String pkg, java.lang.String key, java.lang.String dft)
pkg
- The package namekey
- The localization keydft
- The default localized text
public static I18N.Text parseText(java.lang.String pkg, java.lang.String key, java.lang.String dft, boolean showError)
pkg
- The package namekey
- The localization keydft
- The default localized textshowError
- If true, a stacktrace will be display if the key is invalid.
public static I18N.Text _getString(java.lang.Class clazz, java.lang.String key, java.lang.String dft)
clazz
- The class from which the package is derivedkey
- The localization keydft
- The default localized text
public static I18N.Text getString(java.lang.Class clazz, java.lang.String key, java.lang.String dft)
clazz
- The class from which the package is derivedkey
- The localization keydft
- The default localized text
public static void main(java.lang.String[] argv)
argv
- The command-line args
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |