com.iplanet.am.util
Class Locale

java.lang.Object
  |
  +--com.iplanet.am.util.Locale

public class Locale
extends java.lang.Object

This class Locale.java is a utility that provides functionality for applications and services to internationalize their messages.


Constructor Summary
Locale()
           
 
Method Summary
static java.lang.String convertDateString(java.lang.String srcDateString, java.util.Locale srcLocale, java.util.Locale dstLocale)
          Converts date string from source locale to destination locale
static java.lang.String formatMessage(java.lang.String formatStr, java.lang.Object obj1)
          Util function to format messages using MessageFormat Class
static java.lang.String getDateString(java.util.Date date, java.util.Locale locale)
          Gets date string from date with specified locale.
static java.util.Locale getDefaultLocale()
          Gets the default locale
static java.util.ResourceBundle getInstallResourceBundle(java.lang.String bundle)
          Gets the default install ResourceBundle for the default locale
static java.util.Locale getLocale(java.lang.String stringformat)
          Gets the locale object for the specified localized string format.
static java.util.Locale getLocaleObjFromAcceptLangHeader(java.lang.String langStr)
          Gets locale from accept-language header Http accept language header can have more than one language in the header, we honor the first language as locale
static java.lang.String getLocaleStringFromAcceptLangHeader(java.lang.String langstr)
          Gets locale from accept-language header Http accept language header can have more than one language in the header, we honor the first language as locale
static java.lang.String getNormalizedDateString(java.util.Date date)
          Convert the Date object into ISO-8601 format yyyy/MM/dd HH:mm like 2002/12/23 20:40
static java.util.ResourceBundle getResourceBundle(java.lang.String bundle, java.lang.String stringformat)
          Gets the ResourceBundle corresponding to the specified locale and the localized property file name.
static java.lang.String getString(java.util.ResourceBundle rb, java.lang.String resource, Debug debug)
          Gets the localized string for the specified key
static java.lang.String getString(java.util.ResourceBundle rb, java.lang.String resource, Debug debug, java.util.ResourceBundle defaultRb)
          Gets the localized string for the specified key from the specified Resource or from the specified default resource
static void main(java.lang.String[] args)
           
static java.util.Date parseDateString(java.lang.String dateString, java.util.Locale locale)
          Gets Date object from date string with specified locale.
static java.util.Date parseNormalizedDateString(java.lang.String dateString)
          S1IS stores date in ISO-8601 format yyyy/MM/yy hh:mm Gets the Date object from the date string in ISO-8601 format
static java.lang.String URLDecodeField(java.lang.String strIn, Debug debug)
           
static java.lang.String URLDecodeField(java.lang.String strIn, java.lang.String charset, Debug debug)
           
static java.lang.String URLEncodeField(java.lang.String input, java.lang.String enc)
          This method is replacement function for URLEncoder Function URL encoder function converts input string into URLencoded byte stream after converting Unicode string into bytes using native encoding.
static java.lang.String URLEncodeField(java.lang.String input, java.lang.String enc, Debug debug)
          This method is replacement function for URLEncoder Function URL encoder function converts input string into URLencoded byte stream after converting Unicode string into bytes using native encoding.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Locale

public Locale()
Method Detail

main

public static void main(java.lang.String[] args)

getLocale

public static java.util.Locale getLocale(java.lang.String stringformat)
Gets the locale object for the specified localized string format.
Parameters:
stringFormat - String represntation of the locale. Examples: en_US, en_UK, ja_JP
Returns:
the java.util.locale object

getLocaleStringFromAcceptLangHeader

public static java.lang.String getLocaleStringFromAcceptLangHeader(java.lang.String langstr)
Gets locale from accept-language header Http accept language header can have more than one language in the header, we honor the first language as locale
Parameters:
langstr - Value from Accept-Language header of http
Returns:
String lstr locale string in this format en_US, fr

getLocaleObjFromAcceptLangHeader

public static java.util.Locale getLocaleObjFromAcceptLangHeader(java.lang.String langStr)
Gets locale from accept-language header Http accept language header can have more than one language in the header, we honor the first language as locale
Parameters:
langstr - Value from Accept-Language header of http
Returns:
String lstr locale string in this format en_US, fr

getResourceBundle

public static java.util.ResourceBundle getResourceBundle(java.lang.String bundle,
                                                         java.lang.String stringformat)
Gets the ResourceBundle corresponding to the specified locale and the localized property file name.
Parameters:
bundle - Localized property file name
stringFormat - String representation of the locale
Returns:
java.util.ResourceBundle object

getInstallResourceBundle

public static java.util.ResourceBundle getInstallResourceBundle(java.lang.String bundle)
Gets the default install ResourceBundle for the default locale
Parameters:
bundle - Localized property file name
Returns:
the installResourceBundle object

getDefaultLocale

public static java.util.Locale getDefaultLocale()
Gets the default locale
Returns:
the default Locale object

formatMessage

public static java.lang.String formatMessage(java.lang.String formatStr,
                                             java.lang.Object obj1)
Util function to format messages using MessageFormat Class

parseNormalizedDateString

public static java.util.Date parseNormalizedDateString(java.lang.String dateString)
S1IS stores date in ISO-8601 format yyyy/MM/yy hh:mm Gets the Date object from the date string in ISO-8601 format
Parameters:
dateString - - in the format 2002/12/31 23:59
Returns:
Date object

parseDateString

public static java.util.Date parseDateString(java.lang.String dateString,
                                             java.util.Locale locale)
Gets Date object from date string with specified locale.
Parameters:
dateString - date string
locale - Locale object
Returns:
Date object. null will be returned if error happens

getNormalizedDateString

public static java.lang.String getNormalizedDateString(java.util.Date date)
Convert the Date object into ISO-8601 format yyyy/MM/dd HH:mm like 2002/12/23 20:40
Parameters:
date -  
Returns:
date in ISO8601 format 2002/12/31 11:59

getDateString

public static java.lang.String getDateString(java.util.Date date,
                                             java.util.Locale locale)
Gets date string from date with specified locale.
Parameters:
date - Date object
locale - Locale object
Returns:
date string. null will be returned if error happens

convertDateString

public static java.lang.String convertDateString(java.lang.String srcDateString,
                                                 java.util.Locale srcLocale,
                                                 java.util.Locale dstLocale)
Converts date string from source locale to destination locale
Parameters:
srcDateString - source date string
srcLocale - source Locale object
dstLocale - destination Locale object
Returns:
converted date string. null will be returned if error happens

getString

public static java.lang.String getString(java.util.ResourceBundle rb,
                                         java.lang.String resource,
                                         Debug debug)
Gets the localized string for the specified key
Parameters:
java.util.ResourceBundle - resource bundle
resource - the specified key
debug - the debug instance to which the debug messages need to be printed.
Returns:
the localized string representation

getString

public static java.lang.String getString(java.util.ResourceBundle rb,
                                         java.lang.String resource,
                                         Debug debug,
                                         java.util.ResourceBundle defaultRb)
Gets the localized string for the specified key from the specified Resource or from the specified default resource
Parameters:
java.util.ResourceBundle - resource bundle
resource - the specified key
debug - the debug instance to which the debug messages need to be printed.
java.util.ResourceBundle - Default resource bundle
Returns:
the localized string representation

URLEncodeField

public static java.lang.String URLEncodeField(java.lang.String input,
                                              java.lang.String enc)
                                       throws java.io.UnsupportedEncodingException
This method is replacement function for URLEncoder Function URL encoder function converts input string into URLencoded byte stream after converting Unicode string into bytes using native encoding. The URLEncoder does not work for Sun ONE Identity Server if default encoding is not utf-8, hence this method was written.
Parameters:
input - the input string
enc - the encoding format
Returns:
the encoded string

URLEncodeField

public static java.lang.String URLEncodeField(java.lang.String input,
                                              java.lang.String enc,
                                              Debug debug)
This method is replacement function for URLEncoder Function URL encoder function converts input string into URLencoded byte stream after converting Unicode string into bytes using native encoding. The URLEncoder does not work for Sun ONE Identity Server if default encoding is not utf-8, hence this method was written
Parameters:
input - the input string
enc - the encoding format
debug - the debug instance to which debug messages need to be printed
Returns:
the encoded string

URLDecodeField

public static java.lang.String URLDecodeField(java.lang.String strIn,
                                              Debug debug)

URLDecodeField

public static java.lang.String URLDecodeField(java.lang.String strIn,
                                              java.lang.String charset,
                                              Debug debug)