ariba.util.i18n
Class I18NUtil

java.lang.Object
  extended by ariba.util.i18n.I18NEncodingUtil
      extended by ariba.util.i18n.I18NUtil

public class I18NUtil
extends I18NEncodingUtil

Class I18NUtil provides I18N related constants and utility functions


Field Summary
static java.util.Locale Arabic
           
static java.lang.String EncodingKorean
          We use GB2312 encoding for the korean HTML client.
static java.lang.String EncodingShiftJIS
          We use the non-standard Shift_JIS encoding for the japanese HTML client.
static java.lang.String EncodingUTF8
          We use the standard UTF8 encoding for XML files as well as doing CGI posts to our own server.
static java.util.Locale Hebrew
          Languages that are not defined in java.util.Locale
static java.lang.String Left
           
static java.lang.String LeftToRight
          HTML direction parameter value
static java.lang.String Right
           
static java.lang.String RightToLeft
           
 
Fields inherited from class ariba.util.i18n.I18NEncodingUtil
EncodingASCII, EncodingBig5, EncodingCp1250, EncodingCp1251, EncodingCp1252, EncodingCp1253, EncodingCp1254, EncodingEUC_JP, EncodingEUC_KR, EncodingGB2312, EncodingISO2022CN, EncodingISO2022JP, EncodingISO2022KR, EncodingISO8859_1, EncodingISO8859_2, EncodingISO8859_8, EncodingKSC5601, EncodingMS932, EncodingShift_JIS, EncodingUTF_8
 
Constructor Summary
I18NUtil()
          Class constructor.
 
Method Summary
static boolean enableTooltips(boolean isBrowserNetscape, java.lang.String encodingString, java.util.Locale locale)
          Returns boolean on whether to enable Tooltips
static java.util.Locale getLocale(java.lang.String language, java.lang.String country)
          Create a Locale object from given language, country, variant
static java.util.Locale getLocale(java.lang.String language, java.lang.String country, java.lang.String localeVariant)
          Create a Locale object from given language, country, variant
static java.util.Locale getLocaleFromString(java.lang.String locale)
          Create a Locale object for the locale specified by a String.
static java.util.Locale getParent(java.util.Locale locale)
          Returns the parent Locale of locale.
static boolean isBidirectional(java.util.Locale locale)
          Returns true if locale is Hebrew/Arabic
static boolean isCJK(java.util.Locale locale)
          Returns true if locale is Chinese/Japanese/Korean
static boolean isLatin1(java.util.Locale locale)
          Returns true if locale is Latin-1: English, Danish, Dutch, French, German, Finnish, Icelandic, Irish, Italian, Spanish, Norwegian, Brazilian, Portuguese.
static java.lang.String javaEncodingToIANACharset(java.lang.String encoding)
          call this to get the correct CHARSET string to embed in MIME, HTML, or XML.
static java.lang.String languageDirection(java.util.Locale locale)
          Returns value for HTML direction attribute according to the locale
static java.lang.String languageLeft(java.util.Locale locale)
          Returns value for HTML direction attribute according to the locale
static java.lang.String languageRight(java.util.Locale locale)
          Returns value for HTML direction attribute according to the locale
static java.lang.String mimeEncoding(java.lang.String charset)
          Returns either B or Q mime encoding for the given charset B encoding is BASE64.
static int stringLengthBytes(java.lang.String string, java.lang.String encoding)
          Deprecated. see LocaleSupport.widthInBytes(String, Locale)
static int stringWidthWhenPrinted(java.lang.String string, java.lang.String encoding)
          Deprecated. see LocaleSupport.widthInBytes(String, Locale)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Hebrew

public static final java.util.Locale Hebrew
Languages that are not defined in java.util.Locale


Arabic

public static final java.util.Locale Arabic

LeftToRight

public static final java.lang.String LeftToRight
HTML direction parameter value

See Also:
Constant Field Values

RightToLeft

public static final java.lang.String RightToLeft
See Also:
Constant Field Values

Right

public static final java.lang.String Right
See Also:
Constant Field Values

Left

public static final java.lang.String Left
See Also:
Constant Field Values

EncodingUTF8

public static final java.lang.String EncodingUTF8
We use the standard UTF8 encoding for XML files as well as doing CGI posts to our own server.

See Also:
Constant Field Values

EncodingShiftJIS

public static final java.lang.String EncodingShiftJIS
We use the non-standard Shift_JIS encoding for the japanese HTML client. Because it is super set of standard SJIS.

See Also:
Constant Field Values

EncodingKorean

public static final java.lang.String EncodingKorean
We use GB2312 encoding for the korean HTML client.

See Also:
Constant Field Values
Constructor Detail

I18NUtil

public I18NUtil()
Class constructor.

Method Detail

isLatin1

public static boolean isLatin1(java.util.Locale locale)
Returns true if locale is Latin-1: English, Danish, Dutch, French, German, Finnish, Icelandic, Irish, Italian, Spanish, Norwegian, Brazilian, Portuguese. The Locale language for Icelanic and Irish is unknown, need to update later.

Parameters:
locale - the locale to decide on
Returns:
boolean

isCJK

public static boolean isCJK(java.util.Locale locale)
Returns true if locale is Chinese/Japanese/Korean

Parameters:
locale - the locale to decide on
Returns:
boolean

isBidirectional

public static boolean isBidirectional(java.util.Locale locale)
Returns true if locale is Hebrew/Arabic

Parameters:
locale - the locale to get the encoding string of
Returns:
boolean

languageDirection

public static java.lang.String languageDirection(java.util.Locale locale)
Returns value for HTML direction attribute according to the locale

Parameters:
locale - the locale to get the encoding string of
Returns:
String [RTL|LTR]

languageLeft

public static java.lang.String languageLeft(java.util.Locale locale)
Returns value for HTML direction attribute according to the locale

Parameters:
locale - the locale to get the encoding string of
Returns:
String [Right|Left]

languageRight

public static java.lang.String languageRight(java.util.Locale locale)
Returns value for HTML direction attribute according to the locale

Parameters:
locale - the locale to get the encoding string of
Returns:
String [Right|Left]

javaEncodingToIANACharset

public static java.lang.String javaEncodingToIANACharset(java.lang.String encoding)
call this to get the correct CHARSET string to embed in MIME, HTML, or XML. These are the preferred names as specified in the IANA registry which is referrenced by these standards. For example: mime charset Content-Type: content=text/html charset="CHARSET" encoded words in header =?CHARSET?encoding?text?= html xml

Parameters:
encoding - the encoding string in java form
Returns:
the encoding string in IANA form

mimeEncoding

public static java.lang.String mimeEncoding(java.lang.String charset)
Returns either B or Q mime encoding for the given charset B encoding is BASE64. Q is almost identical to quoted printable. That is, ASCII except for certain characters such as space the have to be escaped. For the full descrition, see rfc.2047 All text can be represented as B. Q is somewhat more legible for Latin scripts since it preserves ASCII

Parameters:
charset - the charset string
Returns:
B or Q mime encoding

getLocale

public static java.util.Locale getLocale(java.lang.String language,
                                         java.lang.String country)
Create a Locale object from given language, country, variant

Parameters:
language - locale language
country - locale country
Returns:
a new Locale object for the given language & country strings.

getLocale

public static java.util.Locale getLocale(java.lang.String language,
                                         java.lang.String country,
                                         java.lang.String localeVariant)
Create a Locale object from given language, country, variant

Parameters:
language - locale language
country - locale country
localeVariant - locale variant
Returns:
a new Locale object for the given language, country, and variant strings.

getLocaleFromString

public static java.util.Locale getLocaleFromString(java.lang.String locale)
Create a Locale object for the locale specified by a String.

Parameters:
locale - Locale description string in the form of Locale.toString() (e.g. "en_US").
Returns:
a new Locale object for the given locale string.

getParent

public static java.util.Locale getParent(java.util.Locale locale)
Returns the parent Locale of locale.

By parent we mean the Locale that logically contains the passed-in Locale (where language is deemed to contain country which is deemed to contain variant.

Thus 'en' is the parent of 'en_US' and 'fr_FR' is the parent of 'fr_FR_var'. Top-level Locales (those that specify languages only) do not have a parent and null is returned.

Parameters:
locale - the Locale, whose parent we wish to find; may not be null
Returns:
the parent Locale or null if there is no parent

enableTooltips

public static boolean enableTooltips(boolean isBrowserNetscape,
                                     java.lang.String encodingString,
                                     java.util.Locale locale)
Returns boolean on whether to enable Tooltips

Parameters:
isBrowserNetscape - someone's still using Netscape?
encodingString - the HTML encoding
locale - the user's Locale
Returns:
enable Tooltips?

stringWidthWhenPrinted

public static int stringWidthWhenPrinted(java.lang.String string,
                                         java.lang.String encoding)
Deprecated. see LocaleSupport.widthInBytes(String, Locale)

Calculate string width in ASCII character when printed. 8859_1 chacaters occupies same width when printed. Japanese Kanji-charcter occupies twice of ASCII character's width. Currentry used in BaseObjectOnServer. and TextUtil.

Parameters:
string - printed string
encoding - string encoding
Returns:
printed width of string

stringLengthBytes

public static int stringLengthBytes(java.lang.String string,
                                    java.lang.String encoding)
Deprecated. see LocaleSupport.widthInBytes(String, Locale)

Calculate byte count of String in specified encoding.

Parameters:
string - string
encoding - encoding
Returns:
byte count of string when string is converted with specified encoding.


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.