|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ora.jsp.beans.locale.LocaleBean
This class contains a number of methods for dealing with localized content. It's used by the com.ora.jsp.tags.generic localization tag handler classes, but can also be used stand-alone.
Field Summary | |
private java.util.ResourceBundle |
bundle
|
private java.lang.String |
bundleName
|
private java.lang.String |
charset
|
private java.text.DateFormat |
dateFormat
|
private java.lang.String |
language
|
private java.util.Locale |
locale
|
private java.text.NumberFormat |
numberFormat
|
private java.util.Hashtable |
parameters
|
private java.util.Locale[] |
requestLocales
|
private java.lang.String |
supportedLangs
|
Constructor Summary | |
LocaleBean()
|
Method Summary | |
java.util.Date |
getDate(java.lang.String date)
Returns the specified date String converted to a Date, parsed as defined by the currently selected locale. |
java.lang.String |
getDateString(java.util.Date date)
Returns the specified Date converted to a String, formatted as defined by the currently selected locale. |
private java.lang.String |
getDecodedValue(java.lang.String value)
This method returns a new String created from the specified String, encoded as 8859_1 converted to the currently set charset. |
private java.util.Locale |
getDefaultLocale()
Returns a Locale for the default language. |
double |
getDouble(java.lang.String number)
Returns the specified number String converted to a double, parsed as defined by the currently selected locale. |
float |
getFloat(java.lang.String number)
Returns the specified number String converted to a float, parsed as defined by the currently selected locale. |
int |
getInt(java.lang.String number)
Returns the specified number String converted to a int, parsed as defined by the currently selected locale. |
java.lang.String |
getLanguage()
Returns the language code for the currently selected locale. |
java.util.Locale |
getLocale()
Returns a Locale. |
long |
getLong(java.lang.String number)
Returns the specified number String converted to a long, parsed as defined by the currently selected locale. |
private java.lang.Number |
getNumber(java.lang.String number)
Returns the specified String as a Number, parsed based on the currently selected locale. |
java.lang.String |
getNumberString(double number)
Returns the specified number converted to a String, formatted as defined by the currently selected locale. |
java.lang.String |
getPageName(java.lang.String basePageName)
Returns a version of the specified page name with a language/country suffix for the currently selected locale. |
java.lang.String |
getParameter(java.lang.String parameter)
Returns the first all value for the specified parameter, parsed using the currently specified charset. |
java.util.Enumeration |
getParameterNames()
Returns an Enumeration of all parameter names. |
java.lang.String[] |
getParameterValues(java.lang.String parameter)
Returns an array of all values for the specified parameter, parsed using the currently specified charset. |
private java.util.Locale |
getSupportedLocale(java.util.Locale[] locales)
Returns the first Locale that matches a supported language, or the default Locale if no match. |
java.lang.String |
getText(java.lang.String resourceName)
Returns the text resource for the specified key, with the best match for the currently selected locale. |
private boolean |
isEqual(java.util.Locale[] arr1,
java.util.Locale[] arr2)
Returns true if the the specifed Locale arrays contains exactly the same locale information. |
private boolean |
isSupportedLang(java.lang.String language)
Returns true if the specified languge is a supported language. |
private void |
resetBundle()
Resets the ResourceBundle. |
private void |
resetLocale()
Resets all locale dependent variables. |
void |
setBundleName(java.lang.String bundleName)
Sets the bundle name. |
void |
setCharset(java.lang.String charset)
Sets the charset used to parse request parameters. |
void |
setLanguage(java.lang.String language)
Sets the user selected language/country code. |
void |
setParameters(java.util.Hashtable parameters)
Sets the parameter list. |
void |
setRequestLocales(java.util.Locale[] locales)
Sets the set of locales received with the request, and resets the currently selected locale if the new set is different from the current set. |
void |
setSupportedLangs(java.lang.String supportedLangs)
Sets the set of supported languages, provided as a comma separated list of country/language codes. |
private java.lang.String |
toLanguage(java.util.Locale locale)
Returns the language/country code for the specified Locale. |
private java.util.Locale |
toLocale(java.lang.String language)
Returns a Locale for the specifed language/country code. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private java.util.Locale locale
private java.util.Locale[] requestLocales
private java.util.ResourceBundle bundle
private java.lang.String supportedLangs
private java.lang.String bundleName
private java.lang.String language
private java.text.NumberFormat numberFormat
private java.text.DateFormat dateFormat
private java.lang.String charset
private java.util.Hashtable parameters
Constructor Detail |
public LocaleBean()
Method Detail |
public java.util.Locale getLocale()
public void setRequestLocales(java.util.Locale[] locales)
public void setSupportedLangs(java.lang.String supportedLangs)
Resets the currently selected locale if the new set is different from the current set. This is done so that all possible locale sources will be evaluated again the next time the locale property is retrieved.
public java.lang.String getLanguage()
public void setLanguage(java.lang.String language)
Resets the currently selected locale if the new language is different from the current. This is done so that all possible locale sources will be evaluated again the next time the locale property is retrieved.
public void setBundleName(java.lang.String bundleName)
Resets the current ResourceBundle so that a new will be created with the new bundle name the next time the ResourceBundle is retrieved.
public void setCharset(java.lang.String charset)
public double getDouble(java.lang.String number) throws java.text.ParseException
public float getFloat(java.lang.String number) throws java.text.ParseException
public int getInt(java.lang.String number) throws java.text.ParseException
public long getLong(java.lang.String number) throws java.text.ParseException
public java.util.Date getDate(java.lang.String date) throws java.text.ParseException
public java.lang.String getNumberString(double number)
public java.lang.String getDateString(java.util.Date date)
public java.lang.String getText(java.lang.String resourceName)
public java.lang.String getPageName(java.lang.String basePageName)
public void setParameters(java.util.Hashtable parameters)
public java.lang.String[] getParameterValues(java.lang.String parameter) throws java.io.UnsupportedEncodingException
public java.util.Enumeration getParameterNames()
public java.lang.String getParameter(java.lang.String parameter) throws java.io.UnsupportedEncodingException
private void resetBundle()
private void resetLocale()
private boolean isEqual(java.util.Locale[] arr1, java.util.Locale[] arr2)
private boolean isSupportedLang(java.lang.String language)
private java.util.Locale getDefaultLocale()
private java.util.Locale toLocale(java.lang.String language)
private java.lang.String toLanguage(java.util.Locale locale)
private java.util.Locale getSupportedLocale(java.util.Locale[] locales)
private java.lang.Number getNumber(java.lang.String number) throws java.text.ParseException
private java.lang.String getDecodedValue(java.lang.String value) throws java.io.UnsupportedEncodingException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |